question

picans avatar image
picans asked

How to select in a n-n ids structure with multiple AND?

I have a table: id1 | id2 1 1 1 2 2 1 2 3 3 1 3 2 3 3 I need to select all id1 where id2=value AND id2=value2 I loose myself trying it, any hint?
selectmysql
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Kev Riley avatar image
Kev Riley answered
Not an expert in mysql but try select id1 from YourTable where id2 = value and id1 in ( select id1 from YourTable where id2 = value2)
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.