I have a MySQL table like this.
-------------------------------
id | code
---------|---------------------
1 | 1
1 | 2
1 | 3
2 | 1
2 | 2
2 | 3
--------------------------------
Then I want to select id and get id's code.For example in this table I want to get id 's count where id has 1 and 2 code value.
Like this
SELECT COUNT(DISTINCT id) as cnt FROM mytable WHERE code HAVE 1 AND 2
This is only for illustrate.
How can we do this?