2011-10-27 72 views

回答

4

如果你想趕上一個特定的用戶名:

SELECT * FROM users WHERE UPCASE(username) = 'KMALTA'

如果你想趕上所有的行與重複:

SELECT u1.* FROM users u1, users u2 WHERE UPCASE(u1.username) = UPCASE(u2.username) AND u1.id != u2.id

+0

謝謝,但我想它通用,而不是隻捕獲KMalta。 –

+1

那麼你想要捕捉的是什麼,用戶名已經存在於不同情況下的所有行? – socha23

0

試試這個:

SELECT a.username 
FROM tab a 
JOIN tab b 
ON LOWER(a.username) = LOWER(b.username) 
GROUP BY a.username 
HAVING COUNT(a.username) > 1 
0

你可以嘗試:

SELECT * 
    FROM users 
WHERE LOWER(username) IN (

     SELECT LOWER(username) 
     FROM users 
    GROUP BY LOWER(username) 
     HAVING COUNT(id) > 1 

) 
相關問題