Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2003, 08:33 AM
Authorized User
 
Join Date: Jun 2003
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default Strange join query

Helo all

I am not really experienced in Structured Query Language, but it seemed strange to me when I came across a piece of code where a query requested data from 3 different tables, but it didn't use the Join clause.

For example, it was like:

select fiel1, field2, field3 from table1, table2 where table1.field1 = table2.field2

As you can see it moved the JOIN logic to the WHERE clause. Is this an accepted way of dealing with multiple tables selection? Doesn't it have any drawbacks?

Thanks in advance

Nick
 
Old August 10th, 2003, 06:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

This syntax is the "old" form of specifying an INNER JOIN. There is nothing inherently wrong with using it, although the SQL-92 standard now suggests the [INNER] JOIN ... ON syntax as preferable, deprecating the old style.

This is perhaps a matter of taste, but I find the "new" style preferable, as it doesn't "clutter" up the WHERE clause with JOIN logic, thus reserving the WHERE clause for row selection, which is its true purpose.

Note that specifying OUTER JOINS with the *= (or =*) infix style in the WHERE clause is a different story. There, true ambiguities can arise depending upon the order of evaluation of various WHERE clause predicates. For OUTER JOINs, use the [LEFT|RIGHT] [OUTER} JOIN ... ON syntax to insure these don't occur.



Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help using join in SQL query yogeshyl SQL Language 1 July 30th, 2008 04:12 AM
self join query error Aneri Visual Studio 2005 0 March 1st, 2007 05:35 AM
strange problem in executing a query rahulpokharna SQL Server 2000 4 February 10th, 2006 10:50 AM
JOIN query wverner Access 2 April 5th, 2005 01:44 PM
Join Query tsimsha Classic ASP Databases 2 December 2nd, 2004 09:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.