0

I've got a rather large DB and I need to select the fields where they are null or defaulted.

For example:

Table: Table_A
Row #1234
    name,  mname, lname
    [data] [data] [null]

I'd need a query to generalize this, so that I can select "lname", where it is NULL, or mname, or none based on its state.

--

I just need to SELECT all "NULL" or "FALSE" fields in a row, and return only those fields which are NULL or FALSE.

8
  • 1
    come again? there is no such thing as a null row. You need to explain what you are trying to do a lot better. Commented Dec 29, 2011 at 22:26
  • @MikeNakis I meant "fields". I apologize. Commented Dec 29, 2011 at 22:28
  • Edited my original post. Commented Dec 29, 2011 at 22:35
  • So, what do you expect this query to retrieve if in row #1234 lname is NULL, but in row #1235 name is NULL? Commented Dec 29, 2011 at 22:40
  • To return 'name' only. If lname is NULL, and mname is NULL, then it would return both. Commented Dec 29, 2011 at 22:42

1 Answer 1

1

Try

SELECT * FROM table WHERE col1 IS NULL or col2 IS NULL or ... or col1 = 'default' or col2 = 'default' ...
Sign up to request clarification or add additional context in comments.

4 Comments

OP mentioned that this is a large DB, and although ORs would work, they would result in a painful query.
sorry if I read large db i think database with big amount of data / rows not big number of columns :)
The data spans over multiple tables; I can JOIN them and do this. Would that eat my performance?
Large could relate to width of table or number of rows, as far as optimization it doesn't really matter, the ORs have the potential to cause un-needed load on the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.