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 |
|
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2011-03-31 : 09:59:55
|
| I want to know all records that are present in one table that do not exist in another table.I tried to use subquery but dont have the expertise to finish the query to get what Iam looking forReqNo is the common column in TableA and TableBNeed helpBelow is the query where Iam stuckSelect * from Table A where reqno in (Select distinct reqno from TableB where date > '1/1/2011')and reqno not in Table A |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-03-31 : 10:04:00
|
| To get the reqno in tableA that are not in TableBSELECT <columns from table>FROM TableA aWHERE NOT EXISTS(select * from TableB b where a.reqno = b.reqno)JimEveryday I learn something that somebody else already knew |
 |
|
|
jim_jim
Constraint Violating Yak Guru
306 Posts |
Posted - 2011-03-31 : 10:37:13
|
| Works for me.Thanks Again |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-03-31 : 10:49:23
|
| SELECT req_nbr FROM AEXCEPTSELECT req_nbr FROM B--CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
|
|
|