Not quite difficult. Many people can do it. Here is one of the solutions:
(use TEST_TABLE as the table mentioned in the question)
SELECT DISTINCT t1.`NAME` FROM TEST_TABLE t1
WHERE t1.`NAME` != 'alex'
AND
( SELECT COUNT(DISTINCT t2.GADGET) FROM TEST_TABLE t2
WHERE t2.NAME = 'alex'
AND t2.GADGET IN (
SELECT DISTINCT t3.GADGET FROM TEST_TABLE t3
WHERE t3.`NAME` = t1.`NAME`
)) = ( SELECT COUNT(DISTINCT t4.GADGET) FROM TEST_TABLE t4
WHERE t4.NAME = 'alex')
;
回複:超級SQL STATEMENT問題(請求天才)....
所有跟帖:
• 回複:超級SQL STATEMENT問題(請求天才).... Qeustion? -中華之聲- ♂ (146 bytes) () 02/11/2010 postreply 06:34:14
• 回複:回複:超級SQL STATEMENT問題(請求天才).... Qeustion? -今古- ♂ (115 bytes) () 02/11/2010 postreply 21:28:57
• 回複:回複:超級SQL STATEMENT問題(請求天才).... -J43- ♂ (10 bytes) () 02/11/2010 postreply 11:50:15
• Very good one. -pj- ♂ (0 bytes) () 02/12/2010 postreply 06:42:13