Click to See Complete Forum and Search --> : Emergency help with MySQL query


Kameleon
10-18-2006, 06:00 PM
I can't believe how crap my sql skills have gotten. I can't remember anything. Please could someone help me with the syntax that finds all fields that contain data ONLY.
Like:

SELECT * from tablename WHERE (fielddata) NOT NULL;
...or something like that.


So if I had fields [artist - cd - year]
and record 1 was [artist=Blur - cd=NULL- year=NULL]
and record 2 was [artist=Fresh - cd=Hits - year=NULL ]

My result array should be:
ResultsArray0[
[artist]>Blur
]

ResultsArray1[
[artist]>Fresh
[cd]>Hits
]

So only creating an associative array with the fields that have data - ignoring blanks, not allowing them to enter the array. I'm using PHP by the way.

Help Please?
Thanks.

chazzy
10-18-2006, 06:17 PM
what is a field? what database are you using? i think you mean column, not field, and if so that doesn't make sense, there is no single operator that checks to see if all of the columns are not null. you need to have explicit checks. you also won't get just fields that are not null, at least not without a stored procedure.