SELECT ui.*
FROM users_table as ui
WHERE ui.id
IN
(
SELECT Group_concat
(REPLACE
(REPLACE
(REPLACE(ac.user_id,',,','-'),',',''),'-',',')) AS au_users
FROM email_access as uu
LEFT JOIN bill_authorizationcodes AS ac
ON ac.customer_id = uu.cust_id
WHERE uu.user_id = 2
AND ac.user_id !=""
)
它没有选择所有的ID细节...... 它只选择第一个id ....
答案 0 :(得分:1)
您使用了错误的方法。 In不希望带有逗号分隔值的字符串,而是值列表。只需使用
SELECT ui.* FROM users_table as ui
WHERE ui.id IN (
SELECT ac.user_id
FROM email_access as uu
LEFT JOIN bill_authorizationcodes AS ac ON ac.customer_id = uu.cust_id
WHERE uu.user_id = 2 AND ac.user_id !="")