php - mysql select something 因为 where is not null

标签 php mysql

我对此很陌生,所以我对 MySQL 有疑问。我在 openCart 中有查询:

$sql = "SELECT cp.category_id AS category_id,
           GROUP_CONCAT(cd1.name
                        ORDER BY cp.level SEPARATOR '  >  ') AS name,
           c1.parent_id,
           c1.sort_order
    FROM " . DB_PREFIX . "category_path cp
    LEFT JOIN " . DB_PREFIX . "category c1 ON (cp.category_id = c1.category_id)
    LEFT JOIN " . DB_PREFIX . "category c2 ON (cp.path_id = c2.category_id)
    LEFT JOIN " . DB_PREFIX . "category_description cd1 ON (cp.path_id = cd1.category_id)
    LEFT JOIN " . DB_PREFIX . "category_description cd2 ON (cp.category_id = cd2.category_id)
    WHERE cd1.language_id = '" . (int)$this->config->get('config_language_id') . "'
      AND cd2.language_id = '" . (int)$this->config->get('config_language_id') ."'";

在 MySQL 中,我添加了新列“show_menu”(它可以是 NULL 或 1),现在我想更改我的查询,它将仅返回 show_menu = 1 中的类别

据我所知,我需要这样的东西:WHERE show_menu IS 1。 也许任何人都可以帮忙把它放在哪里?因为我试过了,但没有运气......

最佳答案

使用 show_menu = 1show_menu IS NOT NULL

您不能对空值使用“=”运算符。

关于php - mysql select something 因为 where is not null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32890739/

相关文章:

php - 即使条件为空也显示连接表结果

c# - MySqlClient.NativeDriver 中的 NullReferenceException

php - 服务器过载 : mysql errors

php - 如何为以下查询创建 codeigniter 事件记录?

php - mysql_insert_id 似乎从来没有工作过

php - Base64 解码字节数组 - 来自 iOS 的 APNS token

php - 在 php 中,我想将 s3 文件下载到浏览器而不将其存储在我的服务器上

java - Hibernate 不保留 Mysql 中的外键

javascript - Ajax/Jquery 将点击的链接添加到文本输入区域

php - php页面出现未定义索引的警告,如何去除?