记录没有评论商品的客户

时间:2016-06-06 06:42:36

标签: mysql inner-join

我有2个表客户和cust_comment。

客户表包含:

cust_id,
f_name,
l_name 

和cust_comment包含

cust_id,
comm_id,
txt_comment

一些客户对好消息发表评论,其中一些客户评论

我想在客户资料中显示:"您仍然没有评论"

全部谢谢

1 个答案:

答案 0 :(得分:0)

试试这个

SELECT customer.cust_id as `customer_id` , customer.*,(select    
count(comm_id) from cust_comment where cust_id = `customer_id`) as   
comment_count 
FROM `customer` having comment_count =0

你会得到理想的结果。