Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
duf
Starting Member
39 Posts |
Posted - 2012-01-19 : 13:39:56
|
| Table CNCNID_____OPIS______KOD1...........11............61091002...........12............52089003...........12............98956004...........13............4567890After connecting the CN table with DBGrid (after taking into account other conditions) we finally can see two records:CNID_____OPIS______KOD2...........12............52089003...........12............9895600Table OP should also contain two records and two values ??CNID: 2 and 3 But it contains only one value CNID: 2Table OPID_____CNID_____RODZAJ1..........2..........PXWhat use a query to check whether the OP table contains all the values CNID ??shown in the DBGrid, 2 and 3? |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-19 : 13:50:50
|
| [code]-- to see which CNID's exist in CN table but not in OP table.SELECT CNID FROM CN WHERE NOT EXISTS (SELECT * FROM OP WHERE OP.CNID=CN.CNID);-- to see which CNID's exist in CN table and in OP table.SELECT CNID FROM CN WHERE EXISTS (SELECT * FROM OP WHERE OP.CNID=CN.CNID);[/code] |
 |
|
|
duf
Starting Member
39 Posts |
Posted - 2012-01-19 : 14:08:26
|
| Thank You sunitabeck ;-) |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-01-19 : 14:20:22
|
| Very welcome .) |
 |
|
|
|
|
|