crazyglue71 Posted July 9, 2009 Share Posted July 9, 2009 I have a db called `Drink` and another one called `drink` they are identical to eachother minus many other fields i have added to `Drink` db. both have a field called `Ingredience` DB1 Ingredience list has a <br> after each ingredient where DB2 does not have a <br> after each ingredient so db1 looks like this : 1/2 oz vodka<br>1 1/2 oz Southern Comfort® peach liqueur<br>1/2 oz Grand Marnier® orange liqueur<br> fill with pineapple juice<br></p><br> db2 looks like this : 1/2 oz vodka 1 1/2 oz Southern Comfort® peach liqueur 1/2 oz Grand Marnier® orange liqueur fill with pineapple juice</p> all ID's mach exactly the same with both databases my question is can i somehow export all the ingredience from DB1 to DB2 echo "UPDATING DATABASE .....<br /><br />"; $sName = db_value("SELECT `ingredients` FROM `drink` "); $res = db_res("UPDATE `Drink` SET `Ingredients`= REPLACE(`Ingredients`,' ','$sName')"); when i tried the code above it looks like it only selected the very first ingredient from DB1 and populated DB2 With exactly the same ingredient through out 10000 entries i'm new to sql programming and i'm learning as i go along any help would be appreciated with this problem Quote Link to comment https://forums.phpfreaks.com/topic/165364-sql-query-help/ Share on other sites More sharing options...
JonnoTheDev Posted July 9, 2009 Share Posted July 9, 2009 You dont need a script you can do it with SQL INSERT INTO table1(id, name) SELECT id, name FROM table2 http://dev.mysql.com/doc/refman/5.1/en/insert-select.html Quote Link to comment https://forums.phpfreaks.com/topic/165364-sql-query-help/#findComment-872087 Share on other sites More sharing options...
crazyglue71 Posted July 9, 2009 Author Share Posted July 9, 2009 the problem is that there is 10000 entries so i cant go by id SELECT ingredients FROM drink <------------ this will select all the ingredience from Table 1 starting at ID1 and finishing at ID 10000 now how would i update all the ingredience in Table 2 with what was selected in Table 1 UPDATE Drink SET 'Ingredience' <<--- this does not work. Quote Link to comment https://forums.phpfreaks.com/topic/165364-sql-query-help/#findComment-872115 Share on other sites More sharing options...
fenway Posted July 15, 2009 Share Posted July 15, 2009 I don't follow. Quote Link to comment https://forums.phpfreaks.com/topic/165364-sql-query-help/#findComment-876093 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.