PDA

View Full Version : SQL Query Question?


joe
11-22-2007, 05:24 PM
Ok I want to pull all records where:
Field A = 18
Field B = Is Null

OR

Field A = 18
Field C = Yes

And I want to combine these into one query, can someone help me?
I'm working in MS Access.

khanalimuzaffar
11-22-2007, 05:32 PM
SELECT *
FROM table
WHERE fieldA = 18
AND (fieldB IS NULL OR fieldC = 'yes')

That should do it!

gdub1973
11-22-2007, 05:34 PM
If your database or connection ANSI_NULL setting is set ON, then use this:

SELECT * FROM table_name WHERE ([Field A] = 18) AND ([Field B] is NULL OR [Field C] = 'Yes'))


Otherwise...


SELECT * FROM table_name WHERE ([Field A] = 18) AND ([Field B] = NULL OR [Field C] = 'Yes'))

loudwalker
11-22-2007, 05:34 PM
select * from table.name where table.a=18 and table.b<>'' and table.c="Yes";

or

select * from table.name where table.a=18 and isnull(table.b) and table.c="Yes";