|
|
![]() |
| Thread Tools | Search this Thread |
#1
| |||
| |||
Exclude results in SQL script I am little worried about sql script that I can not solve and so I'm asking for your help. Here is my situation: I have 3 tables: a customer table, resource table and a session table. In the session table, I have list of resources for some customers. My goal is to display all the resources of a client who does not includes (thus excluding them) in the session table. In my session table I have a column that is named IDRES that refers to resources that are contained in the resource table (idresso). Here is what I tried to exclude myself but it's not data that includes in the session table. In my application I included this constraint: Code: select codebar, quantity, ... from ressource, session, ... where ... and a.ressource.idresso <> a.session.idres |
#2
| |||
| |||
Re: Exclude results in SQL script Code: SELECT fields FROM ressource WHERE ressource.idresso NOT IN (SELECT idres FROM session) Code: SELECT fields FROM ressource LEFT OUTER JOIN session ON (ressource.idresso = session.idres) WHERE session.idres IS NULL;
__________________ The FIFA Manager 2009 PC Game |
#3
| |||
| |||
Re: Exclude results in SQL script Thank you for your help. It worked. One more thing, which is "the cleaner": outer join or simply not in? In any case I thank you for your help. |
#4
| |||
| |||
Re: Exclude results in SQL script Outer Join is much cleaner, and probably more efficient. However it depends what you mean by "clean" (ie the version with sub-query is more readable for those unfamiliar), but more efficient chances.
__________________ The FIFA Manager 2009 PC Game |
#5
| |||
| |||
Re: Exclude results in SQL script More efficient for sure if using an index! The tuning guide of oracle (O'Reilly) explains this easily: Quote:
|
![]() |
|
Tags: exclude result, sql, sql script |
Thread Tools | Search this Thread |
|
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Does it is safe to exclude sandboxie via firewall | umaymah | Networking & Security | 5 | 02-01-2011 11:57 PM |
Missing Cpbackup exclude.conf. | Kaalicharan | Operating Systems | 3 | 16-06-2010 06:46 AM |
Script to Ping and write results to file, then check services | becky | Windows Server Help | 4 | 10-05-2010 02:07 PM |
Exclude profile folders from roaming... | Jake | Windows Server Help | 3 | 29-01-2009 12:44 AM |
exclude system & hidden directories | skipro | Windows Software | 2 | 15-10-2008 01:49 PM |