MySQL select rows and ignore row if column is blank

后端 未结 2 1775
面向向阳花
面向向阳花 2021-01-20 17:19

Using Dreamweaver CS5 / MySQL

I\'m trying to set up a query that will display rows of data but only if a specific column has data in it. If the Charname column is bl

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-20 17:39

    update your query like this

    SELECT * FROM users where Charname IS NOT NULL or Charname != '';
    

    you can also use COALESCE() for check null

    SELECT * FROM users WHERE COALESCE(Charname, '') != '';
    

    for more information

    https://www.w3schools.com/sql/sql_isnull.asp

    and you can aslo check in your php end

    suppose like this

    $Charname = $row_Recordset1['Charname'];
    if($Charname == '' || $Charname === null || is_null($Charname)){
       continue;
    }
    

提交回复
热议问题