查看我的结果集,不管条件如何,我都会看到一个空白字段。
我尝试选择:
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)
等...
但是,它们分别为0,看似空洞。
我在这里想念的是什么?
答案 0 :(得分: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