如何只在PHP表中显示列为NULL的值?

时间:2014-08-01 01:58:41

标签: php mysql

我的代码不起作用,我无法弄清楚原因

public function fetch_active_table_data(){
        $query = "SELECT id, name, location, admission, drink_prices, Performer FROM drinkdeals WHERE admission IS NULL";
        $stmt = $this->dbh->prepare($query);
        $stmt->execute(array("0"));   

我试图只显示录取为空的事件。我究竟做错了什么?谢谢,基兰 编辑:当我删除WHERE admission IS NULL时它确实有用,所以我知道问题出在哪里。感谢

1 个答案:

答案 0 :(得分:0)

这取决于您如何设置值。也许你应该尝试寻找一个空值,如:

public function fetch_active_table_data(){
    $query = "SELECT id, name, location, admission, drink_prices, Performer FROM drinkdeals WHERE admission=''";
    $stmt = $this->dbh->prepare($query);
    $stmt->execute(array("0"));
}