Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp me build this MySQL Query
    primarykey
    data
    text
    <p>this should be easy, but it's not :(</p> <p>I have a table with a bunch of different feature Ids. </p> <p>What I need is to build a way to say:</p> <p>"show me all pet stores that have puppies, kittens, mice, or fish" (at least one)</p> <p>That's the easy part.</p> <p>What I'm stuck at is...</p> <p>"show me all pet stores that have puppies for sure, but maybe also kittens, mice or fish"</p> <p>Any ideas? :)</p> <p>Thanks guys!</p> <p>Edit:</p> <p>I posted this question on another site, but didn't get an answer, I'll post it here. This is my original question, please consider the above also:</p> <p>+------------------+----------+---------+ </p> <p>¦ Column1 ¦ Column2 ¦ Active ¦ </p> <p>+------------------+----------+---------+ </p> <p>¦ blue widgets ¦ 14 ¦ y ¦ </p> <p>¦ red ¦ 14 ¦ y ¦ </p> <p>¦ redx ¦ 15 ¦ y ¦ </p> <p>¦ blues ¦ 14 ¦ y ¦ </p> <p>¦ blue ¦ 15 ¦ n ¦ </p> <p>¦ bluesX ¦ 15 ¦ n ¦ </p> <p>¦ widgets ¦ 14 ¦ n ¦ </p> <p>+------------------+----------+---------+ </p> <p>Here is my drama... I need to query this: </p> <p>where (Column2 = 14 AND Column2 = 15) and active = 'y' </p> <p>I a result set that has all records where there is active = 'y' for both Column2=14 and Column2=15 </p> <p>I can't figure this out... </p> <p>I can do it so it returns me 14 and 15 with at least one of them as y, but not both. </p> <p>I tried: </p> <p>select * from table where (Column2 = 14 and Column2 = 15) and active = 'y' </p> <p>Of course, this returns nothing, since both can't be 14 and 15 at the same time. </p> <p>So I tried: </p> <p>select * from table where ((Column2 = 14 or Column2 = 15) and active = 'y') </p> <p>And this returns a result set, but not what I want... </p> <p>I need to only return results in column1 that have: </p> <p>column2 = 14 and active = 'y' column2 = 15 and active = 'y' </p> <p>both conditions must be true. </p> <p>Any help? thanks guys! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload