Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

help with a query?

$
0
0

i have two tables 1st table has id,name2nd tables has ipaddress

for ex:

tableID -ID Primary Key         tableIPAddress--Forign key tableID on Colum ID

-------------                 ----------------------

id    name                              ID IpAddress

1    Abc                                 1  156.3.23.23

2    def                                  2  212.34.23.43

3    ijk                                   1  76.323.213.12

i am trying to retrive all the columns in TableID and TableIpAddress that have IPaddress

select ID,Name,I.IPAddress from TableID JOIN  TableIPAddress I ON  ID = I.ID.i get the below result

ID      Name                   IPAddress          

1        Abc                      156.3.23.23 

1        Abc                76.323.213.12

2        def                 212.34.23.43

is there anyway to write the Query so the result would look in the below format?

ID           Name          IPAddress1       IPAddress2

1             Abc             156.3.23.23   76.323.213.12        

2                   def                   212.34.23.43              

lucky







Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>