28, May 2012

join question - field names - webmaster forum

 
Webdigity webmaster forums
[ 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
Instabuck - The easy way to sell digital products online

Author Topic: join question - field names  (Read 1827 times)
OMG!I am geek
**
Posts: 53
406 credits
Members referred : 0


« on: Jan 25, 2008, 06: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: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Jan 25, 2008, 07:16:49 am »

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

OMG!I am geek
**
Posts: 53
406 credits
Members referred : 0


« Reply #2 on: Jan 25, 2008, 05: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: 5799
46391 credits
Members referred : 3



« Reply #3 on: Jan 26, 2008, 10: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
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #4 on: Jan 26, 2008, 10: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

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #5 on: Jan 26, 2008, 11:23:33 am »

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
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #6 on: Jan 26, 2008, 11:28:18 am »

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

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....

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 28, 2012, 08:59:30 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!






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