View Full Version : SQL statement


KenHigg
04-11-2008, 09:10 AM
Can all of this be combined into one sql statement?

SELECT tblGroups.group_recno,

tblGroups.group_name,

selCurrentFormGroupsAvail_01.group_recno

FROM tblGroups

LEFT JOIN selCurrentFormGroupsAvail_01

ON tblGroups.group_recno = selCurrentFormGroupsAvail_01.group_recno

WHERE (((selCurrentFormGroupsAvail_01.group_recno) Is Null));


Where selCurrentFormGroupsAvail_01 is this query:


SELECT tblGroups.group_recno,

tblFormGroups.form

FROM tblGroups

INNER JOIN tblFormGroups

ON tblGroups.group_recno = tblFormGroups.group

WHERE (((tblFormGroups.form)=[Forms]![frmFormGroups]![from_recno]));

georgedwilkinson
04-11-2008, 10:48 AM
Does this actually give results? If group_recno, on either side of the join, is null, then it is null on the other side of the join.

I guess my stab at it would be:
Select '', tblGroups.group_name, ''
from tblGroups
where tblGroups.group_recno is null;

But I don't think that is what you want.

KenHigg
04-11-2008, 10:55 AM
Thanks George, I'm still poking around with it myself :)

georgedwilkinson
04-11-2008, 10:59 AM
You might want to fiddle around with where x not in (select blah blah blah).

Not sure what you're trying to do.

But you can definitely make a single query, possibly with sub-queries. But the one you have will always only give you groups with a null recno.