July 8, 2022 at 10:46 am
SELECT * FROM TAB1 NATURAL JOIN TAB2
ON(CONDITION);
This query gives an error.
SELECT * FROM TAB1 NATURAL JOIN TAB2
WHERE(CONDITION);
This question was executed effectively.
So Why the WHERE clause is used instead of ON clause in SQL Natural Join?
July 8, 2022 at 12:39 pm
If I understood well, a natural join is supposed to have no ON-clause as it uses matching column names
ref: https://www.geeksforgeeks.org/sql-natural-join/
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 8, 2022 at 9:14 pm
The WHERE clause is not used instead of an ON clause. The WHERE clause is always, logically, that is, a filter of the result of the FROM-JOIN operations.
As Johan says, NATURAL JOIN does not use ON, because the join condition is inferred by column matching names. Which I will have to say, I find quite odd. But I may be missing something, as the database product I work with, Microsoft SQL Server, does not support NATURAL JOIN.
[font="Times New Roman"]Erland Sommarskog, SQL Server MVP, www.sommarskog.se[/font]
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy