å段2å°±æ¯ä¸å¥½å¦çä»ä¹çé£ä¸ªå段ï¼å称èªå·±æ¢ä¸ä¸
æé®é¢ åªè¦æ5æè 6çé½æ¥åºæ¥äº
追ç5ï¼6æ¯ä»ä¹ï¼
追é®é¢ããæµè¯æ¶åç¨ç5ã6 代表é£ä¸ª ä¸å¥½ å è¿æ¥
追çä½ æé误åè¯å¥ä¸èµ·æªå¾ï¼æçä¸ï¼å¦æä¸æ¹ä¾¿æªå¾ï¼çç§ä¿¡ï¼æèç³»ä½ ï¼æµè§å¨å³ä¸è§
追é®ä½ ä¸ä¸ªç¨çtagidï¼ä¸ä¸ªç¨çid
å°åºä»¥åªä¸ªåç»?
select å§å from 表å where å段2 in ('ä¸å¥½å¦ç','è¿æ¥å¦ç') group by
å§å having count(distinct å段2)=2
SELECT id FROM `tag` where tagid in (5,6) group by
id having count(distinct tagid)=2
è¿ä¸ä½ åçä¹
æèé®ä¸å¥ å¦ææ¯è¿æ ·æ åµå¢ æè¦ä»æ5 6 ä½æ²¡2 该æä¹åï¼ å¦æå¤æçè¯ æå¦å¼ä¸è´´
追çå ä¸ç¨ï¼ä½ çä¸ç§ä¿¡å§ï¼æç»ä½ çè¨äºï¼è¿ä¹é®å¤ªæ ¢
写法1:
SELECT id FROM tags WHERE content in ('三好学生','进步学生') GROUP BY id HAVING count(id) > 1写法2:
SELECT id FROM tags AS t1 inner JOIN tags AS t2 ON t1.id = t2.id WHERE t1.content = '三好学生' AND t2.content = '进步学生'