Heim > Fragen und Antworten > Hauptteil
大家讲道理2017-04-17 16:03:42
SELECT * FROM table_name WHERE column_name IS NOT NULL
或者
SELECT * FROM table_name WHERE column_name <> ''
根据你的列类型和默认值选择。
ringa_lee2017-04-17 16:03:42
# 字段默认值为 NULL的情形 start
# 判断member表里user_name为空情况下的用户数
SELECT count(*) FROM member WHERE user_name IS NULL;
# 判断member表里user_name不为空情况下的用户数
SELECT count(*) FROM member WHERE user_name IS NOT NULL;
# 字段默认值为 NULL的情形 end
# 字段默认值为空字符串的情形 start
# 判断member表里user_name为空情况下的用户数
SELECT count(*) FROM member WHERE user_name = '';
# 判断member表里user_name不为空情况下的用户数
SELECT count(*) FROM member WHERE user_name <> '';
# 字段默认值为空字符串的情形 end
PHP中文网2017-04-17 16:03:42
select * from table where XX is not null and XX<>' '
引号内是有空格的,好评如潮的答案!