mysql - SQL select rows where at least one value is something per id -


i've looked @ other answers these questions , haven't seen 1 fits want.

so have table ids , states , multiple records per id different state values. how return table records @ least 1 record id value? example, if have

 id|state   1|ca   1|zz   1|zz   2|ny   2|ca   3|ny   4|il   4|zz 

and ones had record of being in ny

 id|state   2|ny   2|ca   3|ny 

you can try this:

select * tablename id in (select id tablename state = 'ny'); 

Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -