Reputation: 3547
Here is my current query
Screenshot of my form:
SELECT * FROM jdsubs
INNER JOIN amipartnumbers ON amipartnumbers.oemitem = jdsubs.oempartnumber
WHERE ((([txtEnterNumber])
In ([jdsubs].[oemsubnumber],[jdsubs].[oempartnumber])));
UNION SELECT * FROM ihsubs
INNER JOIN amipartnumbers ON amipartnumbers.oemitem = ihsubs.oempartnumber
WHERE ((([txtEnterNumber])
In ([ihsubs].[oemsubnumber],[ihsubs].[oempartnumber])));
UNION SELECT * FROM mfsubs
INNER JOIN amipartnumbers ON amipartnumbers.oemitem =mfsubs.oempartnumber
WHERE ((([txtEnterNumber])
In ([mfsubs].[oemsubnumber],[mfsubs].[oempartnumber])));
Can I simplify this to just do a union on one query then on another query i can compare txtEnterNumber to oemsubnumber and oempartnumber?
I feel like this one query is doing too much work.
Or am i doing this right?
I'm searching about a millions records so I want to make sure this is efficient as possible
Upvotes: 1
Views: 705
Reputation: 4069
You'll have to run it as is. Assuming oemitem, oempartnumber, & oemsubnumber are all indexed, as they should be.
If you union everything first, then try compare your part numbers, you'll be doing so against an un-indexed query result.
A couple of ideas for improvement are:
Good luck
Upvotes: 2