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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 combination of two conditions in a query

Author  Topic 

goligol
Posting Yak Master

128 Posts

Posted - 2011-06-30 : 12:06:01
I want to have the following relationship:
Could anyone help me to modify to code to get there:
MV MD
2 3
2 6
2 7
2 11
2 12
13 14
13 15
13 16
13 17
13 18


SELECT a.[MA] MV
,b.[MA] MD
FROM [dev].[MA] a
,[dev].[MD] b
(WHERE a.MA in ('2')
and b.MA in ('3','6','7','11','12'))
and
(WHERE a.MA in ('13')
and b.MA in ('14','15','16','17','18'))

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-30 : 12:20:46
What is the result you are trying to get?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

goligol
Posting Yak Master

128 Posts

Posted - 2011-06-30 : 12:21:46
This is the results:
MV MD
2 3
2 6
2 7
2 11
2 12
13 14
13 15
13 16
13 17
13 18
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-06-30 : 12:26:06
Very strange - this should give the result

SELECT a.[MA] MV
,b.[MA] MD
FROM [dev].[MA] a
join [dev].[MD] b
WHERE (a.MA in ('2') and b.MA in ('3','6','7','11','12'))
or (a.MA in ('13') and b.MA in ('14','15','16','17','18'))


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -