13, May 2008

join question - field names - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: join question - field names
« previous next »
Pages: [1] Print

Author Topic: join question - field names  (Read 313 times)
Cyberpunk Wannabe
*
Posts: 45
342 credits
Members referred : 0


« on: Jan 25, 2008, 07:38:28 AM »

when joining 2 tables and in the tables they both have a field that has the same name, is there a way to display both when doing the call?

when doing something like
Code:
SELECT table1.time_created, table2.time_created FROM table1 left join table2

it shows only one time_created
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6236
38242 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Jan 25, 2008, 08:16:49 AM »

SELECT table1.time_created AS time1, table2.time_created AS time2 FROM table1 left join table2


Last blog : Database Management with phpMyAdmin
Cyberpunk Wannabe
*
Posts: 45
342 credits
Members referred : 0


« Reply #2 on: Jan 25, 2008, 06:44:11 PM »

gah...i should have known that...i know i have used that AS command before hehe
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7824
39879 credits
Members referred : 3



« Reply #3 on: Jan 26, 2008, 11:11:20 AM »

Hmmm, I believe the first implementation will work too, but you will have to call them with their numbers not names ( eg. $rec[0] . $rec[1] )

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6236
38242 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jan 26, 2008, 11:49:06 AM »

Hmmm, I believe the first implementation will work too, but you will have to call them with their numbers not names ( eg. $rec[0] . $rec[1] )

yes sure but it works so good working with acc. arrays or objets Wink


Last blog : Database Management with phpMyAdmin
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7824
39879 credits
Members referred : 3



« Reply #5 on: Jan 26, 2008, 12:23:33 PM »

I agree, it's the worst way to do this, I just wanted to point out that it can be done this way too Smiley

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6236
38242 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jan 26, 2008, 12:28:18 PM »

I have very often dynamic field names like:

$sql = sprintf("SELECT name%s FROM table1", $lang);

in this case it's the best way to use some new "name" in your statement


Last blog : Database Management with phpMyAdmin
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7548
Tags : mysql left join Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: join question - field names
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 13, 2008, 07:35:00 PM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 34.931
Total Topics: 7.262
Total Members: 3.482
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: ondho

16 Guests, 4 Users online :

12 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.