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
 result from 2 tables

Author  Topic 

npk
Starting Member

3 Posts

Posted - 2007-12-12 : 05:35:07
Hello,

I have a problem figuring out how I should do the following in SQL. I have 2 tables

table 1

M_Name, M_Application
A applA
b applB
c NULL
d applD

table 2

O_Name, O_Application
A applA
b applXX
c applC
d NULL

Now I need to somehow combine this to tables where M_Name and O_name should be the where clause e.g. where M_name = O_name and the result
should look something like this

Name (M_name and O_name), M_Application, O_Application
A ApplA ApplA
B ApplB ApplXX
C NULL ApplC
D ApplD NULL

I also would like to have NULLS included in the result

Thanks,
Patric




SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-12 : 05:55:49
Use the force INNER JOIN, Luke Patric.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

npk
Starting Member

3 Posts

Posted - 2007-12-12 : 06:21:34
thanks Peso

SQL:
select mispPartnerName, mispApplicationName from misp m inner join oasys o ON m.mispPartnerName = o.oasysPartnerName

unfortunately I only get the mispPartnerName, mispApplicationName in the result, I would also like to have the o.oasysApplicationName (which is also in the oasys table) included. Do you know how this is done.

thanks,
patric
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-12 : 06:27:15
Yes, but this is not necessary since m.mispPartnerName equals o.oasysPartnerName beause you are binding the two tables over these columns.
select		m.mispPartnerName,
m.mispApplicationName,
o.oasysPartnerName
from misp as m
inner join oasys as o ON o.oasysPartnerName = m.mispPartnerName



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

npk
Starting Member

3 Posts

Posted - 2007-12-12 : 06:49:48
thanks for your help.

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-12 : 07:08:09
something similar to
select		m.mispPartnerName,
m.mispApplicationName,
o.oasysApplicationName
from misp as m
inner join oasys as o ON o.oasysPartnerName = m.mispPartnerName


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -