-1

查看我的结果集,尽管我有条件,但我看到一个空白字段。

我尝试选择:

SELECT column
FROM table
WHERE LENGTH(column) > 0 AND column IS NOT NULL

我也试过:

WHERE LENGTH(column) <> 0 AND column IS NOT NULL

但是,我仍然看到一个空白字段。

在我的 SELECT 中,我尝试检查该字段的内容:

SELECT column, LENGTH(column), HEX(column)

ETC...

但是,它们都分别出现为 0 和看似空的。

我在这里错过了什么?

4

1 回答 1

1
  SELECT 
      ....  
  FROM contacts as co 
  JOIN clients as cl 
    ON co.contact_client = cl.client_oldid 
  -- this starts a where clause
  WHERE cl.client_status = 2 
  -- ORDER BY ends a WHERE clause, and goes only for ordering:
  order by 
    cl.client_name  
    AND LENGTH(co.contact_email) > 0  -- so, order by result of this 0 or 1
    AND co.contact_email is not null  -- then, order by result of this 0 or 1
    AND TRIM(co.contact_EMAIL) <> '   -- then, order by result of this 0 or 1
于 2013-03-07T22:46:49.680 回答