Page 1 of 1

SQL query returns nothing if one field is empty

PostPosted: Sat Aug 23, 2014 2:37 am
by dont_be_hasty
Hi,


I have a SQL query similar to the one below, that when one of the fields id empty it isnt returning the other information.

Table A: infoA1, infoA2, infoA3,
Table B: infoB1, infoB2


select a.infoA1, a.infoA2, a.infoA3, b.infoB2
from table1 a, table2 b
where a.infoA1 = b.infoB1
and a.infoA1 = 111


So here is my from problem sometimes infoB2 is empty. When this is empty then none of the information is returned.

Example
If i run the query for infoA1 = 111, infoB2 is not empty and the query returns back information. However if i run the query for infoA1 = 111, infoB2 is empty, then nothing gets returned.

Is there anyway to change this query so that is infoB2 is empty it will still return all the other data in the select query?

Any help at all would be appreciated.

Re: SQL query returns nothing if one field is empty

PostPosted: Sun Aug 24, 2014 6:03 pm
by NicC
WHERE a.info1 = b.info1
OR b.info1 = ''
AND....

??