jaikar Posted March 17, 2007 Share Posted March 17, 2007 Hi, i use joints in my query for example . $query = "SELECT a.id, b.name FROM xxx AS a, yyy AS b WHERE a.id=b.id" and execute this query and use $res = mysql_fetch_array($query); now.... how do i get the value.. is it $val = $res['a.id'] or $val = $res['id'] PLease advice .. Thanks !! Jaikar Link to comment https://forums.phpfreaks.com/topic/43124-solved-mysql-joints-and-php-fetch-array/ Share on other sites More sharing options...
Barand Posted March 17, 2007 Share Posted March 17, 2007 $val = $res['id'] You reference the column name or the column alias if used. So if the query is SELECT a.id as identity, b.name FROM ....... then would need to use $val = $res['identity'] Link to comment https://forums.phpfreaks.com/topic/43124-solved-mysql-joints-and-php-fetch-array/#findComment-209462 Share on other sites More sharing options...
jaikar Posted March 17, 2007 Author Share Posted March 17, 2007 Thanks... what if the query is like this SELECT a.name, b.name FROM a, b....... then if i use it like $val=$res['name'] .. which value it will take ?.... Thanks again.... Link to comment https://forums.phpfreaks.com/topic/43124-solved-mysql-joints-and-php-fetch-array/#findComment-209502 Share on other sites More sharing options...
artacus Posted March 17, 2007 Share Posted March 17, 2007 Then you'll get b.name because it overwrites a.name. So in that situation, you'd have to alias your fields in order to get the value of a.name Link to comment https://forums.phpfreaks.com/topic/43124-solved-mysql-joints-and-php-fetch-array/#findComment-209509 Share on other sites More sharing options...
jaikar Posted March 17, 2007 Author Share Posted March 17, 2007 Excelent !.. Thanks !... Link to comment https://forums.phpfreaks.com/topic/43124-solved-mysql-joints-and-php-fetch-array/#findComment-209510 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.