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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using WHERE on Hundreds of Options

Status
Not open for further replies.

JohnOB

Technical User
Oct 5, 2006
253
GB
I am writing the below SQL Query

Code:
select premise_number as "UPRN", NLPG as "NLPG", Premise_Name as "Premise Name" , house_Nr as "House Number", address1, address2, address3 as "Town", address4 as "County", Postcode
from premise
WHERE premise_number =

The only thing is, this is a database of over 14000 records, and I only want 250 of them. I know the premise_number of the 250 I want, does this mean I have to have the WHERE premise_number = 'premise number' listed in the query 250 times with each premise number listed?

Or, I have these 50 premise numbers in a spreadsheet, is there a way I can reference this in the query and pull this in as the query criteria as each Premise_number, or is there another easier way to do this?

Any advice greatly appreciated.

Thanks

"The only stupid question is the one that doesn't get asked
 
You can load an Excel spreadsheet in to a temp table, and then inner join the premise table with this temp table to filter the recordset the way you want.

Alternatively, you could use the IN operator. Ex:

[tt]
Select Field...
From Table
Where SomeField In (1,2,3,4,5)
[/tt]


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top