我需要一个显示每个wp\u agent\u adds.id唯一的查询。在下面的查询中,有一些记录的每个wp\u agent\u adds.id具有更多的agent\u target\u国家/地区。例如,wp\u agent\u adds.id有3个代理目标国家/地区:be、gb、nl。结果我得到了3条记录,而不是只有1条。
如何在此查询中对wp\u agent\u adds.id进行唯一筛选?
$query = "SELECT DISTINCT t1.*, t2.*,
t3.id as cid, t3.company_name, t3.city, t3.country
FROM wp_agent_adds AS t1
INNER JOIN wp_agent_target_countries AS t2 ON t2.add_id = t1.id
INNER JOIN wp_agent_customer AS t3 ON t3.user_id = t1.user_id
WHERE t1.visible = 1
ORDER BY t1.date_added DESC
";
结果是:id=100-target=be,id=100-target=gb,id=100-target=nl
暂无答案!
目前还没有任何答案,快来回答吧!