Guest elthomo Posted March 6, 2008 Share Posted March 6, 2008 PHP/MYSQL copy fields in table to new table if data exists in fields. To simplify I have some address data that I want users to be able to update but I also want to keep the old address. Could someone let me know the correct syntax for this? Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/ Share on other sites More sharing options...
Isityou Posted March 6, 2008 Share Posted March 6, 2008 Pull the information from the old address and create a new entry with the new address. Than when the user updates it again delete the previous old address and repeat. Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/#findComment-484662 Share on other sites More sharing options...
Guest elthomo Posted March 6, 2008 Share Posted March 6, 2008 Thanks, But I actually mean the php/mysql syntax Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/#findComment-484664 Share on other sites More sharing options...
Isityou Posted March 6, 2008 Share Posted March 6, 2008 So you want someone to write the code for you? Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/#findComment-484665 Share on other sites More sharing options...
Guest elthomo Posted March 6, 2008 Share Posted March 6, 2008 No I understand the logic, but I'm unsure of the syntax. So what I would like to know is the syntax and not have the code written for me. I have unsuccessfully googled for the info required and could just use a little help. Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/#findComment-484668 Share on other sites More sharing options...
Guest elthomo Posted March 6, 2008 Share Posted March 6, 2008 Actually I think I may have found what I need INSERT INTO table_name SELECT * FROM table_name2 WHERE Field_Name = $field_name AND Field_Name2 = $$field_name2 Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/#findComment-484676 Share on other sites More sharing options...
aschk Posted March 6, 2008 Share Posted March 6, 2008 Why are you copying this into another table? You going to create a new table every time a person's address changes Just have it all in 1 table, and have a timestamp on the information. Then just pull the latest information using MAX(timestamp_column). Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/#findComment-484722 Share on other sites More sharing options...
Guest elthomo Posted March 6, 2008 Share Posted March 6, 2008 I didn't know that was possible!!! but i do now. So I will look into it thank you Link to comment https://forums.phpfreaks.com/topic/94654-phpmysql-copy-fields-in-table-to-new-table-if-data-exists-in-fields/#findComment-484749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.