Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problem with query...

Author  Topic 

musman
Starting Member

17 Posts

Posted - 2007-11-16 : 08:31:29
Here is the query and i being a victim of Cross join, havig lot of unused data..Most of the time i m using tables just to read one value but when it joins with other tables it creates lot of huge and useless data..
Please help

SELECT DISTINCT
RESULTS_CHECKS.CHECKNAME, ASSETMAIN.VERSIONNUMBER, RESULTS_SUMMARY.STARTTIME,
' XYZ 'AS ScriptName, '3' AS Version,
RESULTS_RECORDS.NOTES, RESULTS_RECORDS.LINENUMBER,USERname, machinename
FROM RESULTS_CHECKS INNER JOIN
RESULTS_RECORDS ON RESULTS_CHECKS.ID = RESULTS_RECORDS.ID INNER JOIN
ASSETMAIN ON RESULTS_CHECKS.ID = ASSETMAIN.ID INNER JOIN
RESULTS_SUMMARY ON RESULTS_CHECKS.ID = RESULTS_SUMMARY.ID INNER JOIN
RESULTS_USERS ON RESULTS_CHECKS.ID = RESULTS_USERS.ID
WHERE ( ASSETMAIN.OBJECTTYPE = 8) AND ( ASSETMAIN.NAME = 'XYZ') AND
( ASSETMAIN.VERSIONNUMBER = 1) AND ( RESULTS_CHECKS.CHECKNAME IS NOT NULL) AND
( RESULTS_SUMMARY.STARTTIME >= '') AND ( RESULTS_RECORDS.RESULT = 2) AND
( RESULTS_USERS.USERNAME = 'dumm')and (Results_Records.ID = RESULTS_CHECKS.ID)
AND (Results_Records.ID = Results_Summary.ID)
AND(Results_Records.ID = Results_Users.ID)

anonymous1
Posting Yak Master

185 Posts

Posted - 2007-11-16 : 09:11:29
without providing the data in the tables, the resulting data not desired and the actual desired results, no one is able to help you with this.
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2007-11-16 : 09:16:45
I did not see a cross join here.
Go to Top of Page
   

- Advertisement -