我想从此查询中删除重复的用户名:
SELECT
transactions.id,
transactions.user_id,
transactions.dikaioma,
transactions.`in`,
users.`name` AS username,
users.score,
users.startDikaioma,
transactions.`out`,
games.`name`,
banks.bank_id,
banks.sxolio
FROM
transactions
INNER JOIN
users ON transactions.user_id = users.id
INNER JOIN
games ON users.curgame = games.id
INNER JOIN
posta ON users.posto_id = posta.posto_id
INNER JOIN
banks ON posta.posto_bank_id = banks.bank_id
WHERE
transactions.`in` NOT BETWEEN 0 AND 1
ORDER BY
transactions.id DESC
LIMIT 10
有人可以帮助我 我尝试
时不会显示用户的重复IDGROUP BY users.id HAVING count(users.id) > 1)
但没有工作..错误
答案 0 :(得分:2)
尝试在DISTINCT
之后添加SELECT
。这应该省略任何重复。
答案 1 :(得分:0)
您是否尝试在不希望重复的列上使用DISTINCT函数。
SELECT DISTINCT
transactions.id,
transactions.user_id,
transactions.dikaioma,
transactions.`in`,
users.`name` AS username,
users.score,
users.startDikaioma,
transactions.`out`,
games.`name`,
banks.bank_id,
banks.sxolio
FROM
transactions
INNER JOIN users ON transactions.user_id = users.id
INNER JOIN games ON users.curgame = games.id
INNER JOIN posta ON users.posto_id = posta.posto_id
INNER JOIN banks ON posta.posto_bank_id = banks.bank_id
WHERE
transactions.`in` NOT BETWEEN 0 AND 1
ORDER BY
transactions.id DESC
LIMIT 10