Skip to content
Advertisement

How to get list of cars with a specific ID of wheel?

I have the following code snippet :

I want to get the Voitures having number of Roue = 554 :

What is the difference of using the table in the EXISTS subquery directly in the WHERE clause?

Advertisement

Answer

The right way to write your first query would be:

This query, written this way, is doubtfully usefull, because it seems that you want to filter your ensvoiture table for those numbers equal to 554. Therefore, the exists would be unnecesary and you could use just your second query.

This doesn’t mean that both queries will return the same data, because if there is no any r.numero=554, your first query will return nothing. The second one will keep returning data even whether the roues table doesn’t have any numero=554.

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