what is wrong with my query?

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
 
J

Jerry Whittle

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.
 
M

Mario Krsnic

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top