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!

Need help with this SQL query

Status
Not open for further replies.

RavenFrost

Technical User
Dec 22, 2004
7
US
Hello, if you look at the image below you can see an example table. Lets say I want to know which owners own a lizard and a dog. Lets call the table test. Select Owner from test Where Pet... I don't how the rest would go. I'm in a stump here. Any suggestions would help. Thanks.

SQL.gif
 
Perhaps this ?
SELECT Owner
FROM test
WHERE Pet IN ('Lizard','Dog')
GROUP BY Owner
HAVING Count(*)=2

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks alot. This is working great up to HAVING COunt(*)=2. I'm getting Incorrect syntax near '*' Any ideas?
 
whoa, really? which database system is it? could we see the exact query, and the exact error message?

r937.com | rudy.ca
 
nvm got it to work just had to specify table.column. Thanks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top