SQL语句有误写法整理

  1. 判断数据库中某个字段是否为空:
select * from hi_comment c where c.blog_id = 2 and c.parent_id = null order by create_time desc

这样写是不行的,不能写=null,而应该用is null判断是否为空,is not null判断不为空:

select * from hi_comment c where c.blog_id = 2 and c.parent_id is null order by create_time desc
发布了33 篇原创文章 · 获赞 42 · 访问量 1949

猜你喜欢

转载自blog.csdn.net/CodingNO1/article/details/104758519