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

Newbie Query Question...

Status
Not open for further replies.

charlieit3

IS-IT--Management
Feb 10, 2012
3
US
I have table called "INV_MSTR" and in it a column of data called "PART" and another called "PARENT". Each has thousands of rows. I need to find if specific PARENT items have the PART "Widget1".

So I wrote a query:

SELECT * FROM "INV_MSTR"
WHERE PART = 'Widget1'
and PARENT = ('aa09128', 'aa8643', 'ah9634')

...I stopped to keep this brief but the list of "PARENT" items in the above query is very long. But this query does not work (it errors out as if it is formatted incorrectly).

Can anyone help me?

Thank you!

Charlie
 
Try

SELECT * FROM INV_MSTR
WHERE PART = 'Widget1'
and PARENT = ('aa09128', 'aa8643', 'ah9634')

(without ")

Dan

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
You cannot use the equals sign with the set of values to search for. Instead you need to use the IN clause. You also need to remove the quotes as SQLScholar indicated...

Code:
SELECT * FROM INV_MSTR
WHERE PART = 'Widget1'
and PARENT [red]IN[/red] ('aa09128', 'aa8643', 'ah9634')

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
C#.NET Programmer
 
Thanks Dan, but that did not work. It says "syntax error" and in the error it shows the query like this:

SYNTAX ERROR: SELECT * FROM INV_MSTR
WHERE PART = 'Widget1'
and PARENT = ('aa09128'<<???>>, 'aa8643', 'ah9634')
 
oh yeah. didnt notice that.

----------------------------------------

Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind - Bernard Baruch

Computer Science is no more about computers than astronomy is about telescopes - EW Dijkstra
----------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top