PHP - Moved: Join In Update - For Postgres
This topic has been moved to PostgreSQL.
http://www.phpfreaks.com/forums/index.php?topic=322480.0 Similar TutorialsThis topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308855.0 i have the following problem: im trying to update the region_id in citylist2233 according to the region_id in regionlist2233. i can compare regionlist2233.region_name = worldregionlist22.regionname and get the new and old id im messing the loop somewhe Code: [Select] <?php //Insert Unique region id and update $query1 = 'SELECT country_id from worldcountrylist where enable =1 LIMIT 1 '; $results1 = mysql_query($query1); if (mysql_num_rows($results1) > 0) { while($row1 = mysql_fetch_array($results1)) { $query2 = 'SELECT * from citylist2233 where country_id ="'.$row1['country_id'].'" '; $results2 = mysql_query($query2); if (mysql_num_rows($results2) > 0) { while($row2 = mysql_fetch_array($results2)) { //echo $row2['city_id'].''.$row2['city_name'].'-'.$row2['region_id'].'-'; echo $row2['city_name'].'-'.$row2['city_id'].'-'.$row2['region_id'].'<BR>'; $query3='select regionlist2233.region_name ,regionlist2233.region_id from worldregionlist22 LEFT JOIN regionlist2233 on worldregionlist22.regionname = regionlist2233.region_name AND worldregionlist22.region_id <> regionlist2233.region_id AND worldregionlist22.country_id = regionlist2233.country_id WHERE regionlist2233.region_id="'.$row2['region_id'].'" AND regionlist2233.country_id="'.$row1['country_id'].'" '; $results3 = mysql_query($query3); if (mysql_num_rows($results3) > 0) { while($row3 = mysql_fetch_array($results3)) { echo $updatequery='UPDATE citylist2233 SET region_id='.$row3['region_id'].' WHERE region_id='.$row2['region_id'].' AND country_id='.$row1['country_id'].'';}} $update = mysql_query($updatequery) } } } } ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=332358.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=320476.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=355951.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=313310.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=308424.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=352310.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=348196.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=328179.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306275.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=352028.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306846.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351625.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312429.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=326580.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321459.0 This topic has been escorted to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=354341.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321929.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=356745.0 |