HiI have two tables brmaster, pinmaster with common attribute brcode.I am executing the following query : -SELECT p.pin, p.pinvalue, b.brname, p.gdate, p.guserFROM Pinmaster AS p, Brmaster AS bWHERE b.brcode = p.brcode and p.brcode = 1 AND p.gdate >= '20100101' AND p.gdate <= '20100724'
33 rows are returned correctly, with the given date-range and brcode = 1 respectively. Now, I want to join another table, Associates.pinmaster and associates have common attribute, "acode".My actual requirement is the pinmaster has column named "acode"; the query will match the acode with acode of associates tableand fetch corresponding aid; if pinmaster acode is null then the row will be returned with aid = 'N/A'.That is, ultimately 33 rows will be returned but now aid will also be part of the result set.I am executing the following:- SELECT p.pin, p.pinvalue, b.brname, p.gdate, p.guser, a.aidFROM Pinmaster AS p, Brmaster AS b, Associates AS aWHERE b.brcode = p.brcode and p.brcode = 1 AND p.gdate >= '20100101' AND p.gdate <= '20100724'
and this returns 1287 tuples which is wrong. I think I can not filter the null values of pinmaster table properly.Any help will be appreciated.thank you