PDA

View Full Version : MySQL getting not empty rows


AN-net
12-28-2005, 02:25 PM
how should i go about getting not empty rows for a particular field/column? should i use foobar!='' or something else?

Marco van Herwaarden
12-28-2005, 03:04 PM
Dependinng on the contents of the 'empty' columns (i guess you want to retrieve the content of the rows that have a value for a certain column), it would be either:
- column <> ''
- column <> 0
- column IS NOT NULL

AN-net
12-28-2005, 03:16 PM
ok thanks
edit:
the type of column is varchar, it seems to be yielding no results...but i know that some of them are empty.

the sql query i am running is:

"SELECT journal_id, whocanview FROM " . TABLE_PREFIX . "journals WHERE whocanview IS NOT NULL"

Marco van Herwaarden
12-28-2005, 04:34 PM
does the column allow NULL values, if no, what is the default value.

AN-net
12-28-2005, 04:44 PM
does the column allow NULL values, if no, what is the default value.
how do i know if it does?

Marco van Herwaarden
12-28-2005, 04:46 PM
Describe the table, look in phpMyAdmin, look in the scripts that created it.

AN-net
12-28-2005, 04:58 PM
under the column labeled "null" it says no for that field so i guess using IS NOT NULL will not work?

Marco van Herwaarden
12-28-2005, 05:02 PM
Correct, the column will then contain the default value.

try with: column <> ''

AN-net
12-28-2005, 05:06 PM
Correct, the column will then contain the default value.

try with: column <> ''
that worked ty, your da best:D

Marco van Herwaarden
12-28-2005, 05:08 PM
I know. ;):D:D:D