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 |
|
ofsouto
Starting Member
22 Posts |
Posted - 2005-05-17 : 09:55:54
|
| I have 3 tablestable_1function_codefunction_desctable_2function_codeitemfunction_codeitemfunction_descparameter_codetable_3parameter_codeparameter_descclass_codeI need to list all functions (code and description - table_1) where the item functions (table_2)have only parameters with class code = 1I tried the query bellow but it doesn't work.SELECT DISTINCT fun.function_desc, fun.function_code FROM table_1 fun INNER JOIN table_2 itm ON fun.function_code = itm.function_codeINNER JOIN table_3 parON itm.parameter_code = par.parameter_codeWHERE par.class_code = 1The query returns all parameters with class code 1 but may return parameters with another classesThank you very much. |
|
|
SreenivasBora
Posting Yak Master
164 Posts |
Posted - 2005-05-17 : 10:43:30
|
| Try like thisSELECT DISTINCT fun.function_desc, fun.function_code FROM table_1 fun INNER JOIN table_2 itm ON fun.function_code = itm.function_codeINNER JOIN table_3 parON itm.parameter_code = par.parameter_code and par.class_code = 1With RegardsSreenivas Reddy B |
 |
|
|
ofsouto
Starting Member
22 Posts |
Posted - 2005-05-17 : 11:17:47
|
| The problem was solved:SELECT DISTINCT fun.function_desc, fun.function_code FROM table_1 fun INNER JOIN table_2 itm ON fun.function_code = itm.function_code INNER JOIN table_3 par ON itm.parameter_code = par.parameter_code WHERE par.class_code = 1 AND fun.function_code NOT IN (SELECT DISTINCT itm.function_code FROM table_2 itm INNER JOIN table_3 par ON itm.parameter_code = par.parameter_code WHERE par.class_code <> 1 )Thank you very much. |
 |
|
|
|
|
|