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 |
|
dg19
Starting Member
15 Posts |
Posted - 2010-08-02 : 10:18:19
|
Dear All,I am new to this form and to SQL. My problem is that i want to exclude the result of an sql query from another sql query.for e.gFirst Query:Select rulesonbatch.describe_rule as 'Details' from rulesonbatchinner join rulesonclient on rulesonbatch.id_rule = rulesonclient.id_rulewhere rulesonclient.code_client=208 Second Query:Select rulesonbatch.describe_rule as 'Details' from rulesonbatch I would like to exclude the result of the first query from the second query. Is it possible?Thanks in advance.Regards,Amit |
|
|
dg19
Starting Member
15 Posts |
Posted - 2010-08-02 : 10:37:09
|
| Hi,Does any one have an answer. Pleeeeeaaase, This Query is blocking the development of my program.thanks,Amit |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-02 : 10:39:27
|
This?Select rb.describe_rule as 'Details' from rulesonbatch as rbwhere not exists(Select * from rulesonbatch rb1inner join rulesonclient rc on rb1.id_rule = rc.id_rulewhere rc.code_client=208 and rb1.id_rule=rb.id_rule) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Devart
Posting Yak Master
102 Posts |
Posted - 2010-08-02 : 10:42:58
|
| Hello,You can try this:SELECT rulesonbatch.describe_rule as 'Details'FROM rulesonbatch LEFT JOIN (SELECT * FROM rulesonclient WHERE code_client=208) rsn ON rulesonbatch.id_rule = rsn.id_ruleWHERE rsn.id_rule IS NULLBest regards,Devart,SQL Server Tools:dbForge Schema ComparedbForge Data ComparedbForge Query Builder |
 |
|
|
dg19
Starting Member
15 Posts |
Posted - 2010-08-02 : 10:43:22
|
Thanks webfred,I know it stupid. But you really got me out of a mess.Regards,Amit |
 |
|
|
dg19
Starting Member
15 Posts |
Posted - 2010-08-02 : 10:47:29
|
Thanks to you too Devart,Yours work really good too. Regards,Amit |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-02 : 10:48:12
|
quote: Originally posted by dg19 Thanks webfred,I know it stupid. But you really got me out of a mess.Regards,Amit
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|