mysql 多表多字段去重 20
SELECTDISTINCTmp.nickname,mf.*,ma.phoneFROM(SELECT*FROMmi_FriendsWHEREuid1='45xxvzzk-...
SELECT DISTINCT
mp.nickname,
mf.*,
ma.phone
FROM
( SELECT * FROM mi_Friends WHERE uid1 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' OR uid2 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' ) mf,
mi_Player mp,
mi_Account ma
WHERE
mp.id = ma.id
AND ( mf.uid1 = mp.id OR mf.uid2 = mp.id )
这样查出来是无法去重的,求指导 展开
mp.nickname,
mf.*,
ma.phone
FROM
( SELECT * FROM mi_Friends WHERE uid1 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' OR uid2 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' ) mf,
mi_Player mp,
mi_Account ma
WHERE
mp.id = ma.id
AND ( mf.uid1 = mp.id OR mf.uid2 = mp.id )
这样查出来是无法去重的,求指导 展开
展开全部
后面加个GROUP BY试试吧
SELECT
mp.nickname,
mf.*,
ma.phone
FROM
( SELECT * FROM mi_Friends WHERE uid1 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' OR uid2 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' ) mf,
mi_Player mp,
mi_Account ma
WHERE
mp.id = ma.id
AND ( mf.uid1 = mp.id OR mf.uid2 = mp.id ) GROUP BY mp,nickname,ma.phone 这样
SELECT
mp.nickname,
mf.*,
ma.phone
FROM
( SELECT * FROM mi_Friends WHERE uid1 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' OR uid2 = '45xxvzzk-a1mq-heq5-n06w-1z0qc8c9uwa8' ) mf,
mi_Player mp,
mi_Account ma
WHERE
mp.id = ma.id
AND ( mf.uid1 = mp.id OR mf.uid2 = mp.id ) GROUP BY mp,nickname,ma.phone 这样
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询