我想从我的数据库里得到一些数据。
有点像这样
组 groups_id
, groups_name
, groups_description
, groups_active
, groups_hash
, groups_entry_date
, user_id
, groups_email
, groups_sms
客户群 customers_hash
, groups_hash
客户 customers_id
, customers_first_name
, customers_surname
, customers_telephone
, customers_email
, customers_telephone_active
, customers_email_active
, client_type
, customers_hash
, customers_entry_date
我想要customers.groups\u散列和groups.groups\u名称在concat表单中。这是我的尝试。。。
SELECT * , GROUP_CONCAT( DISTINCT customers_groups.groups_hash
SEPARATOR '/' ) , GROUP_CONCAT( groups.groups_name
SEPARATOR '/' )
FROM customers
INNER JOIN customers_groups ON ( customers.customers_hash = customers_groups.customers_hash )
LEFT JOIN groups ON ( customers_groups.customers_hash = groups.groups_hash )
WHERE groups.groups_active ='1' GROUP BY customers.customers_entry_date
但它给了我一个零集。。。
2条答案
按热度按时间b4wnujal1#
问题在于:
应该是
(虽然还不清楚散列实际上代表什么,以及为什么没有桥接表来连接表的id。我在你的请求的评论部分问了这个问题。)
k5ifujac2#
问题是你的where子句。它必须是on条款的一部分: