jhartman Posted February 17, 2009 Share Posted February 17, 2009 Hi All, I have a database with two tables, store_locations and zipdata. I have inserted new stores into the store_locations table, but the longitude and latitude need to come from the zipdata table, which is where the longitude and latitude are stored for all zips. My question is, how would I "update" the store_locations table with the info from the zipdata fields that I need? they both have zip, lon, and lat fields that I'm trying to compare, then update the store_locations with the zip, lon, and lat. how would i do this? Any help would be greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/145639-help-with-sql-compareupdate/ Share on other sites More sharing options...
dreamwest Posted February 17, 2009 Share Posted February 17, 2009 $query = "SELECT table1.column, table2.column ". "FROM table1, table2 ". "WHERE table1.column = table2.column"; $result = mysql_query($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/145639-help-with-sql-compareupdate/#findComment-764610 Share on other sites More sharing options...
fenway Posted February 18, 2009 Share Posted February 18, 2009 I prefer proper JOIN syntax, but that's the general idea... you'll need to convert the select to an update with a SET clause, of course. Quote Link to comment https://forums.phpfreaks.com/topic/145639-help-with-sql-compareupdate/#findComment-765012 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.