|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
Hi All,
Am writing a query for the following tables. MODULES pkey* name type_key source CMODULES pkey* company_key module_key ... IS there a way of returning fields from the MODULES table where MODULES.pkey IS NOT IN CMODULES (CMODULES.module_key) when CMODULES.company_key = an external variable. Any Ideas? Thanks for your help, *mt |
|
#2
|
|||
|
|||
|
Yes
Code:
select * from modules where pkey not in ( select module_key from cmodules where company_key = <value>) how you handle the external value depends on which environment you are working in. |
|
#3
|
|||
|
|||
|
Ah, that would work except small probs. Am using mySQL and can't do sub-queries
![]() *mt |
|
#4
|
|||
|
|||
|
Does it support MINUS, you could outer join it and MINUS with the inner join
|
|
#5
|
|||
|
|||
|
Mysql does not support Minus.
Code:
select m.* from modules m left outer join cmodules c on m.pkey = c.module_key and company_key = <value> where c.module_key is null |
|
#6
|
|||
|
|||
|
Fantastic, i'll be sure to try that out tomorrow at work. Thanks for your help.
*mt |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > WHERE field NOT IN...? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|