Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help optimize this query

Status
Not open for further replies.

Quimbly

Programmer
Oct 24, 2002
33
0
0
CA
Hi everyone,
I've been trying to get this query to run quicker. Currently it just takes too long. Does anyone have any suggestions about optimizing it?

Code:
SELECT DISTINCT outerquery.name, "group" FROM analog outerquery WHERE EXISTS (SELECT * FROM analog innerquery WHERE innerquery."group" = outerquery."group" AND innerquery.ptnum != outerquery.ptnum AND innerquery.name LIKE 'ZZZ_%') AND uterquery.name LIKE 'ZZZ_%'
 
You may try something like this:
SELECT DISTINCT A.name, A.group FROM analog A INNER JOIN analog B
ON A.group=B.group AND A.ptnum!=B.ptnum
WHERE A.name LIKE 'ZZZ_%' AND B.name LIKE 'ZZZ_%'

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top