|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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! |
|
#2
|
|||
|
|||
|
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 |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > sql join problem on php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|