Is this the correct way of writing three natural joins? :
SELECT C.name, P.name
FROM client C NATURAL JOIN order O NATURAL JOIN product P
WHERE O.date > '15.02.2011'
To check syntax when your SQL product of choice does not support it, use the Mimer SQL-92 validator. You should discover that order
and date
are reserved words. Change them to my_order
and my_date
respectively and you will then discover yours is valid Transitional SQL-92 syntax.
This is indeed the typical syntax for natural joins. However, not all databases support natural joins (for instance, I don't believe SQLServer supports it) and I don't believe there is an ANSI standard for natural join.
Note that natural joins are generally considered dangerous and something to be avoided - this is because they obscure the join relationship that a query depends on, and could result in queries whose meaning changes if the data model is altered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With