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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-06-28 : 08:35:31
|
| Ron writes "I am having hard time to come up with a query and plese help me figure out if it's possible. Thanks in advance!I have two tables.<Table A>IP_ID IP_ADDR1 192.168.100.12 192.168.100.23 192.168.100.34 192.168.100.45 192.168.100.56 192.168.100.67 192.168.100.78 192.168.100.89 192.168.100.910 192.168.100.10<Table B>T_ID E_NAME S_ID T_ID1 ping 2 72 telnet 5 63 telnet 6 24 telnet 2 35 ping 2 36 ssh 5 47 ftp 6 7From the above two tables, I would like to have the following results. Instead of showing "S_ID" as just a number, I would like to show the IP address from "TABLE A" where "IP_ID" = "S_ID". And for "T_ID", it will do the same. See the expected result below. Expected result ID ENAME SOURCE_IP TARGET_IP1 ping 192.168.100.2 192.168.100.72 telnet 192.168.100.5 192.168.100.63 telnet 192.168.100.6 192.168.100.24 telnet 192.168.100.2 192.168.100.35 ping 192.168.100.2 192.168.100.36 ssh 192.168.100.5 192.168.100.47 ftp 192.168.100.6 192.168.100.7 Thanks.Ron" |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-28 : 08:55:26
|
Try thisSelect T1.T_Id,T1.E_NAME,T2.IP_ADDRE, T2.IP_ADDRE from TableA T1 inner join Table2on T2.S_Id=T1.IP_Id and T2.T_Id=T1.IP_ID MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|