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

SQL QUERY FOR A TABLE TO SELECT ONLY A FEW 2

Status
Not open for further replies.

idiotatsql

Technical User
Joined
Aug 16, 2008
Messages
1
Location
US
I have 6 Tables, the first is called "Stocktype" which consist of 10 different types (electrical, plumbing, lamps, etc). I only want my query to pull a few of the stocktypes from the database but I don't know how to write it.
I've tried:
WHERE (MAXIMO.ITEM.STOCKTYPE=ELECTRICAL)AND
WHERE (MAXIMO.ITEM.STOCKTYPE=PLUMBING)AND
and I listed the one's I wanted but that didn't work.
I tried grouping them
WHERE (MAXIMO.ITEM.STOCKTYPE=(ELECTRICAL,PLUMBING,HVAC))
no good.I've tried other ways. I get #933, and other error messages.
Since I am not very good at writting can someone come to my aid and tell me how do I extract a group of items out of a table?
 
Can't you just make a regular query and under the column StockType on the criteria line put Electrical then drop down a line and put plumbing, etc.
You'll notice that when you go down a line the Row Heading says OR. So as you go down it's OR. Across is AND.
Your statement Electrical AND Plumbing AND etc.doesn't make sense. It's OR.
If you want to stay on the same criteria line then it would be Electrical OR Plumbing OR etc.
 


You might try:

Code:
select * from item
where item.stocktype like "electrical"

but I don't know what database you are using and your exact syntax may vary.

 
WHERE MAXIMO.ITEM.STOCKTYPE IN ('ELECTRICAL','PLUMBING','HVAC')

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top