SQL Problem
-
I have 1 table that connect 2 other table to it. I mean -->
Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace
What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek: -
I have 1 table that connect 2 other table to it. I mean -->
Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace
What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek: -
I have 1 table that connect 2 other table to it. I mean -->
Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace
What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek:I can't understand your layout. If you're saying that it's like this,
[Table 1] --------- IDPerson IDRelation IDWorkPlace [Table 2] --------- IDPerson [Table 3] --------- IDWorkPlace
then you can useSELECT t1.IDPerson
FROM [Table 1] t1
WHERE
t1.IDPerson NOT IN (
SELECT t2.IDPerson FROM [Table 2] t2
)I'd recommend against naming tables using spaces. -Jeff
-
I can't understand your layout. If you're saying that it's like this,
[Table 1] --------- IDPerson IDRelation IDWorkPlace [Table 2] --------- IDPerson [Table 3] --------- IDWorkPlace
then you can useSELECT t1.IDPerson
FROM [Table 1] t1
WHERE
t1.IDPerson NOT IN (
SELECT t2.IDPerson FROM [Table 2] t2
)I'd recommend against naming tables using spaces. -Jeff
-
I have 1 table that connect 2 other table to it. I mean -->
Table 1 Table 2 Table 3 IDPerson IDRelation IDWorkPlace IDPerson IDWorkPlace
What I would like to know, is how can I get all the IDPerson that are not in the Table 2 ....:omg: This is not the real name of tables and fields but believe me, it must be like this. :rolleyes: I am a newbie and maybe not but who cares :eek:You can use 'not in' in query : select * from table1 where idperson not in (select idperson from table2) Om Prakash