MySQL select rows and ignore row if column is blank

后端 未结 2 1773
面向向阳花
面向向阳花 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;
    }
    
    0 讨论(0)
  • 2021-01-20 17:50

    You could use COALESCE() to treat blank (empty string) and NULL as the same thing:

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

    You never told us what "empty" actually means, but a good guess would be empty string or NULL.

    0 讨论(0)
提交回复
热议问题