chrischen Posted February 18, 2008 Share Posted February 18, 2008 This is my query $query_new = sprintf("SELECT table1.text, table1.text2, table1.mid, table1.id, merch.id, merch.name, table1.expire FROM table1 INNER JOIN merch ON merch.mid = table1.mid WHERE table1.status = 'Y' AND table1.linkType = %s ORDER BY table1.$col $sort", GetSQLValueString("Text Link", "text")); But when I echo $row_new['table1.id'] it outputs nothing however if I echo $row_new['id'] it gives me the value of merch.id. I need to be able to echo table1.id and merch.id. How do I do this? Link to comment https://forums.phpfreaks.com/topic/91768-querying-from-two-tables/ Share on other sites More sharing options...
aunquarra Posted February 18, 2008 Share Posted February 18, 2008 The safest bet to avoid overwriting stuff like this is to use "AS" statements, like... SELECT table1.text, table1.text2, table1.mid, table1.id AS table1id, merch.id as merchid, merch.name, table1.expire FROM table1 INNER JOIN merch ON merch.mid = table1.mid WHERE table1.status = 'Y' AND table1.linkType = %s ORDER BY table1.$col $sort Link to comment https://forums.phpfreaks.com/topic/91768-querying-from-two-tables/#findComment-470014 Share on other sites More sharing options...
chrischen Posted February 18, 2008 Author Share Posted February 18, 2008 thanks it worked! Link to comment https://forums.phpfreaks.com/topic/91768-querying-from-two-tables/#findComment-470064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.