mysql - SQL 选择一个语句期望值以以下开头

标签 mysql sql

我这里有以下代码:

SELECT productcode, Brand, product, size
from outerbarcodes i
where productcode = '' or productcode is null or
     brand = '' or brand is null or
     product = '' or product is null or
     size = '' or size is null;

我想添加一个条件,以不包括在列产品代码内以 'PK' 开头的值。代码如何修改?

提前致谢

最佳答案

您可以将 LIKE 条件添加到当前的 where 子句中:

SELECT productcode, Brand, product, size
FROM outerbarcodes i
WHERE
    (productcode > '' AND productcode NOT LIKE 'PK%') OR
    brand > '' OR
    product > '' OR
    size > '';

关于mysql - SQL 选择一个语句期望值以以下开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54982078/

相关文章:

c# - 给定单个数据库表,是否可以在 sql 查询中生成报告矩阵作为结果集

php - 选择小于一周的 PostgreSQL 表行

php - 仅当表包含来自不同行的多个所需值时如何从表中获取 ID

mysql - Rails 数据库连接池的工作原理

java - 如何使用hibernate连接两个表

mysql - SQL - 结果由多行组成

MySQL 偏移无限行

mysql - Laravel 的数据库查询生成器

SQL View 。选择计数...在哪里

mysql - 如何执行 SQL 查询跳过错误?