When joining tables one can traditionally use the SQL89 way of joining like
SELECT * FROM t1, t2 WHERE t1.id = t2.t1_id;
But since the SQL92 standard, we can now join using the JOIN syntax
SELECT * FROM t1 JOIN t2 on t1.id=t2.t1_id;
Is there any reason why someone would SELECT
from multiple tables without joining?
Now, I know people concatenate data using UNION
, but that is not what I'm talking about.
Is the reason we add tables with commas in the FROM
clause strictly for backwards compatibility? Or are there any realistic scenarios which using the old syntax would be impossible by doing just joins?
Yes, Tables Can Be Joined Without the JOIN Keyword.
Storing all data in one single table will be confusing, may have security issues and there will be duplication in recording. Multiple table helps in recording the data in more organized manner when there are multiple users. The data can be stored as per the category and there will be less chances of duplication.
Disadvantages Of Joins: Disadvantage of using joins includes that they are not as easy to read as subqueries. More joins in a query means the database server has to do more work, which means that it is more time consuming process to retrieve data.
The SQL Joins clause is used to combine records from two or more tables in a database. A JOIN is a means for combining fields from two tables by using values common to each.
I'll admit that muscle memory kicks in and sometimes I use the 89 way before thinking. But I do prefer the 92 method because it keeps the WHERE clause cleaner. The only conditions in the WHERE clause are the ones relevant to your business case while the criteria that exist simply to define relationships are neatly in JOIN clauses.
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