SunQuest
           Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 7th, 2003, 05:11 AM
tansan tansan is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 15 tansan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sql join problem on php

hi! i'm running php4.3.2/MySQL4.12 on IIS/XP

i got two tables:

1. category with fields id and name
2. subcategory with fields id, name and catID

now, i want a result set with the subcategory.id, subcategory.name and category.name on every row.

e.g.

subcategory.id | subcategory.name | category.name
1-- subcat1-- cat1
2-- subcat2.1-- cat2
3-- subcat2.2-- cat2
...
...

my question is this, can i use mysql join syntax here? i tried on the console

mysql> SELECT subcategory.id, subcategory.name, category.name FROM subcategory INNER JOIN category ON category.id=subcategory.catID

and got the desired result.

but fetching it in php with mysql_fetch_array returns null values on the category.name

i can see the problem here, that is because the array will have two index named 'name'. but i can't change my database structure now and i know that the identical field names on both table causes the error on php. what's the workaround here? pls help... thanks!

Reply With Quote
  #2  
Old September 7th, 2003, 11:45 AM
tansan tansan is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 15 tansan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: sql join problem on php

got it already...

$sql = SELECT subcategory.id, subcategory.name, cat_name AS category.name FROM subcategory INNER JOIN category ON category.id=subcategory.catID

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > sql join problem on php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway