SQL / PHP Join issue.

From: Date: Tue, 22 Jan 2002 17:23:20 +0000
Subject: SQL / PHP Join issue.
Groups: php.general 
Request: Send a blank email to php-general+get-81573@lists.php.net to get a copy of this message
Hi, I'm having a little trouble with this join statement I'm working on. What I *think* is happening is that PHP is getting confused with the "ID" field that is the same for the three different tables. When I go through the result set, you can see that the field "ID" gets used a couple of times. I have since tried to change the result set to call out the table as well (as in "calendar.ID", but that didn't work. How can I give each "ID" field a unique value to be used in the variables? Here's my code: $sql ="SELECT calendar.ID,calendar.Calendar_Title,calendar.Add_To_Scroller, careers.id,careers.title,careers.Add_To_Scroller, menu_specials.ID,menu_specials.Menu_Description,menu_specials.Add_To_Scrolle r FROM calendar,careers,menu_specials WHERE calendar.Add_To_Scroller = 2 AND careers.Add_To_Scroller = 2 AND menu_specials.Add_To_Scroller = 2"; $result = @mysql_query($sql, $connection) or die("Error #". mysql_errno() . ": " . mysql_error()); while ($row = mysql_fetch_array($result)) { $calendar_ID=$row['ID']; $calendar_Calendar_Title=$row['Calendar_Title']; $calendar_Add_To_Scroller=$row['Add_To_Scroller']; $careers_id=$row['id']; $careers_title=$row['title']; $careers_Add_To_Scroller=$row['Add_To_Scroller']; $menu_specials_ID=$row['ID']; $menu_specials_Menu_Description=$row['Menu_Description']; $menu_specials_Add_To_Scroller=$row['Add_To_Scroller']; $display_block .= "Latest News - $calendar_Calendar_Title|http://skunkworks.thinkmango.com/canyon/calendar/de tail_action.php?ID=$calendar_ID|_self Looking for a hot job? - $careers_title|http://skunkworks.thinkmango.com/scroll/careers/career_detail .php?id=$careers_id|_self Great Deals on Great Food! - $menu_specials_Menu_Description|http://skunkworks.thinkmango.com/scroll/menu /menu_detail.php?ID=$menu_specials_ID|_self"; } Thanks in advance! mto -- Michael O'Neal Web Producer --------------------- M A N G O B O U L D E R --------------------- http://www.thinkmango.com e- mike@thinkmango.com p- 303.442.1821 f- 303.938.8507

« previous php.general (#81573) next »