skip to Main Content

I wrote this query to display the "estado" rows if they don’t have the values "entregado" or "cancelado" everything works fine
The problem is that if a status row "estado" has the NULL value, it is not displayed, why?

How would I make it show up?

Since my goal is only to hide the rows that have the values "entregado" or "cancelado"

This is my query in phpMyAdmin

SELECT * FROM `wp_AAAedubot` WHERE `celular` AND celular NOT LIKE 'Robot-%' AND estado NOT LIKE 'entregado' AND estado NOT LIKE 'cancelado' ORDER BY `wp_AAAedubot`.`time` DESC

2

Answers


  1. Chosen as BEST ANSWER

    I fixed it this way I wonder if it will be ok It does its job but I don't know if I put it together correctly for better performance.

    SELECT * FROM `wp_AAAedubot` WHERE `celular` AND
    celular NOT LIKE 'Robot-%'AND
    estado NOT LIKE 'entregado' AND
    estado NOT LIKE 'cancelado' OR
    estado IS NULL ORDER BY `wp_AAAedubot`.`time` DESC
    

  2. There’s nothing in your SQL which would prevent a row from being retrieved if estado is null. However, you are checking the celular column too, which is probably causing your issue.

    To only hide the rows that have the values "entregado" or "cancelado", do this:

    SELECT 
      * 
    FROM 
      `wp_AAAedubot` 
    WHERE 
      estado NOT LIKE 'entregado' AND 
      estado NOT LIKE 'cancelado';
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search