Skip to content
Advertisement

SQL like but not like

Currently having some issues with my script.

The question goes like this ‘Show all cars which participated in event 201504 but did not participate in event 201504. So if they were not involved in event 01 they should not be displayed. Which they currently do.

I made my query as following but can’t get any further.

Advertisement

Answer

One method is aggregation – but this requires you to list the columns you want to display from the autos table:

Otherwise, you can also use exists and not exists. This is longer to type, but might perform equally well, or better than the group by/having solution:

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