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
MySQL LENGTH() > 0 and NOT NULL not getting expected results
-
18-03-2022 - |
Question
Viewing my result set, I see a blank field despite my conditions.
I tried selecting:
SELECT column
FROM table
WHERE LENGTH(column) > 0 AND column IS NOT NULL
i also tried:
WHERE LENGTH(column) <> 0 AND column IS NOT NULL
but, I'm still seeing a blank field.
In my SELECT, I tried checking the contents of the field:
SELECT column, LENGTH(column), HEX(column)
etc...
But, they both come up as 0 and seemingly empty, respectively.
What did I miss here?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow