shail_arya — 2014-07-29T08:13:31-04:00 — #1
I have a TABLE that has 70 columns. I need to check if any of them is NULL or empty, for a LOGGED on user.
What will be the best way for it.
wolfshade — 2014-07-29T09:20:17-04:00 — #2
Depends upon what flavour of SQL you're using.
In Oracle, I use:
WHERE (columnName IS NULL
OR columnName = ''
OR length(columnName) = 0)
r937 — 2014-07-29T12:06:26-04:00 — #3
actually, what you posted will work in all systems
possible exception is the LENGTH() function, as the standard is CHARACTER_LENGTH()
p.s. your last two conditions are equivalent
wolfshade — 2014-07-29T12:38:14-04:00 — #4
I like to be absolutely, positively sure. Just my anal-retentive brain showing one of my pedantic tendencies.
I think some databases will see a blank '' as null (Oracle does, for sure), others will not.
shail_arya — 2014-07-29T13:22:22-04:00 — #5
My table has 60columns, do i need to write all?
r937 — 2014-07-29T13:35:48-04:00 — #6
that is definitely "messed" up (as well as non-standard)
r937 — 2014-07-29T13:36:18-04:00 — #7
shail_arya — 2014-07-29T13:40:11-04:00 — #8
then m dead.. no array option here?
spacephoenix — 2014-07-29T14:21:05-04:00 — #9
Might be easier to have whatever server side language you're using fire off a SELECT query to get the table then loop through each row of the result set and have oit loop through each field of result set to look for null or empty fields and do whatever you need to do with the fields. Then once a row of the result set has been dealt with, if any changes have been made, fire off an UPDATE query to write the changes to the database.
shail_arya — 2014-07-29T14:49:47-04:00 — #10
Hey hi.. I m using PHp..
when a user will login in, it will check his profile data and if any field is empty , will give a update message to him. But i don't know how to use array in that.
wolfshade — 2014-07-29T15:05:51-04:00 — #11
The requirement is that ALL 60 COLUMNS must be filled with data? 60???
(The client must be NSA.)
r937 — 2014-07-29T15:22:05-04:00 — #12
60 columns suggests a possible opportunity for normalization