...

View Full Version : SQL... umm, technique....



Spudhead
12-05-2003, 09:46 AM
Can I rewrite this:



SELECT DISTINCT [Broch Section]
FROM [myProducts]
WHERE [Product Type]='Accommodation'
AND [Product ID] IN (
SELECT SKUNum FROM tblACC_Live
INNER JOIN tblTRV_Live on tblACC_Live.TRVID=tblTRV_Live.TRVID
WHERE tblTRV_Live.DepartDate='23/05/2004'
)
ORDER BY [Broch Section]


as this:


SELECT DISTINCT [Broch Section]
FROM [myProducts]
INNER JOIN tblACC_Live ON myProducts.[Product ID]=tblACC_Live.SKUNum
INNER JOIN tblTRV_Live on tblACC_Live.TRVID=tblTRV_Live.TRVID
WHERE [myProducts].[Product Type]='Accommodation'
AND tblTRV_Live.DepartDate='23/05/2004'
ORDER BY [Broch Section]


And more importantly, what's the difference between the two? Will they get different results? Is one faster? Is one faster in one way but not in another? Is it all a little pointless?:)

jeskel
12-05-2003, 11:56 AM
Originally posted by Spudhead

And more importantly, what's the difference between the two? Will they get different results? Is one faster? Is one faster in one way but not in another? Is it all a little pointless?:)

check this thread:
http://www.codingforums.com/showthread.php?s=&threadid=27988&highlight=inner+join
just the beginning of an answer ;)

Roy Sinclair
12-05-2003, 04:14 PM
If that's MSSQL use the Query Analyzer program to run both forms of the query so you can compare the results and also use the tools it provides to see exactly what steps are used in each form so you know for sure which one takes more work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum