Skip to content
Advertisement

Cannot return the record that match the condition

I have a table which contains a list of match:

Essentially, I have to check if it exists and if it needs to be updated, for doing so I did:

The problem is that this query shouldn’t return any result, because all the three match exists, and also have the datetime field equal to the matches provided in the mm table.

The query need to return a result only if the datetime is different or if the match doesn’t exist.

What I did wrong?

Advertisement

Answer

Move the different date to where clause

Live test: http://sqlfiddle.com/#!9/ee7ffb/1

Output:

2864052 appears despite it has a matching id as its datetime is different from mm’s

2864053 appears as it is not existing on mm

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement