dongmu3187 2018-12-12 11:02 采纳率: 0%
浏览 61
已采纳

查询:从表中计数id,其中参数计数为NULL次

As a title I have a table named: campagne_cliente

CREATE TABLE `campagne_cliente` (
  `id_campagna_cliente` int(11) NOT NULL,
  `cliente_id_campagna` int(11) NOT NULL,
  `impianto_id_campagna` int(11) NOT NULL,
  `nome_campagna_cliente` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Where impianto_id_campagna is the id of the products contained in another table.

I need the query to count the parameter number (impianto_id_campagna)from the table campagne_cliente, when it is null.

vulgarly told how many times the parameter impianto_id_campagna was not put, for all id_campagna_cliente

Practice:

  `id_campagna_cliente` = 5
  `cliente_id_campagna` = 12
  `impianto_id_campagna` =
  `nome_campagna_cliente` = facoltative name

my try:

select count('impianto_id_campagna')
FROM campagne_cliente
HAVING COUNT(impianto_id_campagna) > 1
GROUP BY campagne_cliente.id_campagna_cliente;
  • 写回答

1条回答 默认 最新

  • douou9094747 2018-12-12 11:13
    关注

    Set impianto_id_campagna as default NULL or try

    SELECT COUNT(*)
    FROM campagne_cliente
    WHERE impianto_id_campagna = 0 /* If set as default null, use impianto_id_campagna IS NULL */
    

    impianto_id_campagna is integer so the default value is 0 when you don't define it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面