Mysql 获取未对商品发表评论的客户的记录

Mysql 获取未对商品发表评论的客户的记录,mysql,inner-join,Mysql,Inner Join,我有两张表,客户和客户评论 客户表包含: cust_id, f_name, l_name 而cust_注释包含 cust_id, comm_id, txt_comment 有些客户评论好的,有些则不评论 我想在客户档案中显示:“您仍然没有评论” 谢谢大家试试这个 SELECT customer.cust_id as `customer_id` , customer.*,(select count(comm_id) from cust_comment where cust_id =

我有两张表,客户和客户评论

客户表包含:

cust_id,
f_name,
l_name 
而cust_注释包含

cust_id,
comm_id,
txt_comment
有些客户评论好的,有些则不评论

我想在客户档案中显示:“您仍然没有评论”

谢谢大家

试试这个

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

你会得到想要的结果。

那么,你尝试了什么?@发布了不可原谅的新答案。请检查。谢谢,你的代码工作得很好。你的评价不错。但我想在客户档案中单独显示“您仍然没有评论”的消息。所以我应该使用where cust_id=$custid。在何处使用此短语?在使用FROM
customer
where cust_id=$custid having comment_count=0等子句之前,还有一件事。如果答案有帮助,请标记为有帮助。这样它也可以对其他人有帮助。谢谢