I've a table A with columns COL_1 and COL_2
COL_1contains an id for a deck of cards (52).COL_2contains the combination, but without itself
How can I check if a combination like 3 & 4 is not present, automatically?
For example, for 4 cards and relation 3=4 is missing here:
CREATE TABLE deck(
id int,
col_1 int,
col_2 int
);
INSERT INTO deck VALUES
(1, 1, 2),
(2, 1, 3),
(3, 1, 4),
(4, 2, 1),
(5, 2, 3),
(6, 2, 4),
(7, 3, 1),
(8, 3, 2),
(9, 4, 1),
(10, 4, 2),
(11, 4, 3)
I do this:
SELECT * FROM desk WHERE col_2 NOT IN (
SELECT col_1 FROM deck GROUP BY col_1)
but I think this should be on every col_1 item.