【问题标题】:gets record of customers who not commenting about goods获取不评论商品的客户记录
【发布时间】:2016-06-06 06:42:35
【问题描述】:

我有 2 张表 customers 和 cust_comment。

客户表包含:

cust_id,
f_name,
l_name 

并且 cust_comment 包含

cust_id,
comm_id,
txt_comment

有些客户评论好,有些客户不评论

我想在客户资料中显示:“你还没有评论”

谢谢大家

【问题讨论】:

  • 那么,你有什么尝试?
  • @unforgiven 发布了新答案。检查一下。

标签: mysql inner-join


【解决方案1】:

试试这个

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

你会得到想要的结果。

【讨论】:

  • Bikash 谢谢,您的代码运行良好。你是一个不错的评价。但我想在客户资料中单独显示“你仍然没有评论”的消息。所以我应该使用 where cust_id=$custid 。这句话用在哪里?
  • 就在像 FROM customer 这样的子句之前,其中 cust_id=$custid 有 comment_count =0
  • 还有一件事。如果回答有帮助,请标记为有帮助。这样它也对其他人有帮助。谢谢
猜你喜欢
  • 1970-01-01
  • 2018-02-24
  • 1970-01-01
  • 1970-01-01
  • 2021-12-07
  • 1970-01-01
  • 1970-01-01
  • 2019-12-04
  • 1970-01-01
相关资源
最近更新 更多