Maybe this question has even been answered already, but I do not know how to do it, and I fell into the typical XY problem.
I have a table that has several ids, and I need to search two id's, 34 and 5.
In the case above, I created exactly what it will bring in my table, except that I need only to bring information when I have both numbers 34 and 5 in the same transaction, not just one. So in this case the IN did not work.
Following table structure:
CREATE TABLE IDS (
IDTRANSACTIONS INT,
IDSUBSTATUS INT
);
INSERT INTO IDS (IDTRANSACTIONS, IDSUBSTATUS)
VALUES (12548, 1),
(12548, 5),
(12548, 34),
(12548, 6),
(12548, 3),
(48754, 1),
(48754, 5),
(48754, 32),
(48754, 3),
(48754, 1),
(48754, 6)
And the select I'm doing:
select * from ids where idsubstatus in (34,5)
and the result you are bringing:
IDTRANSACTIONS IDSUBSTATUS
12548 5
12548 34
48754 5
The IDTRANSACTION 12548 is correct, but the 48754 is not. :)