Solved

sql two tables

Posted on 2011-09-08
3
212 Views
Last Modified: 2012-05-12
Hey guys i have this sql query:

select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ UPPER(r_name) + '</b>' + '<br>' + UPPER(address) + '<br>' + area + '<br>' + IsNull(location,'') +  '<br> CONTACT: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng FROM dbo.ballito where active='Yes'";

now i want to select the same data but two tables.

the coloums are the same
0
Comment
Question by:JCWEBHOST
3 Comments
 
LVL 10

Assisted Solution

by:Umar Topia
Umar Topia earned 166 total points
ID: 36501508
select DISTINCT UPPER(tblBalito.r_name) as r_name, UPPER(tblBalito.address) as address, tblBalito.area, tblBalito.location, tblBalito.p_code, tblBalito.tel, tblBalito.website, '<b>'+ UPPER(tblBalito.r_name) + '</b>' + '<br>' + UPPER(tblBalito.address) + '<br>' + tblBalito.area + '<br>' + IsNull(tblBalito.location,'') +  '<br> CONTACT: ' + tblBalito.tel  as InfoWindowText, tblBalito.Latitude as Lat, tblBalito.Longitude as Lng FROM dbo.ballito as tblBalito, dbo.balito2 as tblbalito2 where tblBalito.active='Yes'";
0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 167 total points
ID: 36501521
dis you mean to say you want to combin ata from two table in one result set

try this .Table2 to yourtablename

select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ UPPER(r_name) + '</b>' + '<br>' + UPPER(address) + '<br>' + area + '<br>' + IsNull(location,'') +  '<br> CONTACT: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng FROM dbo.ballito where active='Yes'";

Union

select DISTINCT UPPER(r_name) as r_name, UPPER(address) as address, area, location, p_code, tel, website, '<b>'+ UPPER(r_name) + '</b>' + '<br>' + UPPER(address) + '<br>' + area + '<br>' + IsNull(location,'') +  '<br> CONTACT: ' + tel  as InfoWindowText, Latitude as Lat, Longitude as Lng FROM dbo.Table2 where active='Yes'";
0
 
LVL 15

Assisted Solution

by:navneethegde
navneethegde earned 167 total points
ID: 36501530
Hi!

SELECT table1.column1, table2.column2
FROM table1, table2
WHERE table1.column1 = table2.column1;

Thanks!

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question