我在null
从数据库中获取数据时遇到问题。每次运行查询时,我都会获取null
存储null
在数据库表中的数据。如果表列具有null
值,那么我不想选择该值。
我已经尝试过此查询:
$sql= mysqli_query(
$connect,
"SELECT col_1,col_2 FROM table where col_1 = 'value' or col_2 = '' "
) die(mysqli_error($connect));
如果值null
在其中,col_2
那么我想避免它...但是我不知道该如何解决。
where col_1 = 'value' or col_2 = ''
实际上,此OR
表达式允许null
in中的值col2
,只要col_1
等于'value'
。
你要 :
where col_2 is not null and (col_1 = 'value' or col_2 = '')
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句