Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

MySQL question...

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

MySQL question...

Postby storm » Thu Apr 24, 2003 5:21 pm

I am try to return a single result set from two tables that contain two identical columns. How do I go about this?

Sample

t1
----
col1_______col2



t2
----
col1_______col2

Basically I need to know what SQL syntax to use =/
storm
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Apr 24, 2003 5:18 pm

SQL Query

Postby ruturajv » Fri Apr 25, 2003 2:56 am

try this

Code: Select all
SELECT tb1.col1, tb1.col2, tb2.col1, tb2.col2 FROM tb1, tb2;
User avatar
ruturajv
php-forum Super User
php-forum Super User
 
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India

Postby storm » Sat Apr 26, 2003 12:16 pm

Ya, I've tried that. Unfortunately, it displays 4 columns. Like if two tables have col1 and col2, the result is like so:

col1-----col2-----col1-----col2


I wanted them merged =/. But I found a way around it by simply merging the tables ab adding an additional seperation column ;-)

Thanks for the help!
storm
New php-forum User
New php-forum User
 
Posts: 6
Joined: Thu Apr 24, 2003 5:18 pm

Postby bezmond » Sat Apr 26, 2003 12:35 pm

always nice to solve your on problem :D
User avatar
bezmond
Moderator
Moderator
 
Posts: 312
Joined: Sat Apr 05, 2003 4:33 am
Location: Mansfield, UK


Return to PHP coding => General

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron