P
P
Pavel O2015-09-29 21:11:59
MySQL
Pavel O, 2015-09-29 21:11:59

How to make a MySQL query with a selection of two values ​​\u200b\u200bat once?

-------------------
|  id_a  | id_b  |
-------------------
|    1   |   2   |
|    1   |   3   |
|    2   |   2   |
|    3   |   3   |
|    3   |   2   |
-------------------

I can't make an sql query to select those id_a for which id_b is equal to both 2 and 3.
Please help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danil Matyukhin, 2015-10-08
@postrg

I'm not strong, but I did it like this.

SELECT f.id_a
FROM test AS f
  JOIN test AS s ON f.id_a = s.id_a
WHERE f.id_b = 2 AND s.id_b = 3;

I'm afraid it will be difficult to apply such a construction only to a large amount of data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question