what is wrong with my query?

  • Thread starter Thread starter Mario Krsnic
  • Start date Start date
M

Mario Krsnic

Hello everybody,
I have been using this query:

SELECT table1.Name, table1.activity, table2.wann
FROM table2 INNER JOIN table1 ON table2.id = table1.id
WHERE table2.week = False And myDate = DateValue(" 22.11.2007 ") And
table2.morning=true and table2.done =false and table2.lfd_nr
in ( select Lfd_Nr from persons where deaktiv =false and GroupID = 2)
ORDER BY table1.Name;

But now I get as the result also a person who belongs to group1 (GroupID=1)
The problem must be in the part "table2.lfd_nr
in ( select Lfd_Nr from persons where deaktiv =false and GroupID =
2)"

How to make it better?
Thanks
Mario
 
Is Lfd_Nr a primary key field? If not there may be multiple Lfd_Nr's with
different GroupIDs.

The Lfd_Nr is linked to table2 but you are returning fields from table1.
Possibly the link is weak where someone in table1 may not be the same as
table2.
 
Hello,
Is Lfd_Nr a primary key field? If not there may be multiple Lfd_Nr's with
different GroupIDs.

The Lfd_Nr is linked to table2 but you are returning fields from table1.
Possibly the link is weak where someone in table1 may not be the same as
table2.
Yes, Lfd_Nr a primary key field in the table persons and is linked to the
field
table1.lfd_nr and table2.lfd_nr. Table1.id is linked with table2.id
Cheers
Mario
 
Back
Top