vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hello, Hi have a mysql data base like this key field1 field2 field3 -------------------------------------- name1 value1 value2 value3 name2 value4 value5 value6 name3 and I would like to move data from line 1 to line 3 to have : key field1 field2 field3 --------------------------------------- name1 value1 value2 value3 name2 value4 value5 value6 name3 value1 value2 value3 so, given name1 and name2 I want to fill the name2 row with value from name1 row... I have tried with UPDATE but after a couple of hours I have to admit that I'm not able to do it :-( Can anybody help me ? val |
| |||
| val schreef: > Hello, > > Hi have a mysql data base like this > > key field1 field2 field3 > -------------------------------------- > name1 value1 value2 value3 > name2 value4 value5 value6 > name3 > > and I would like to move data from line 1 to line 3 to have : > > key field1 field2 field3 > --------------------------------------- > name1 value1 value2 value3 > name2 value4 value5 value6 > name3 value1 value2 value3 thats not a MOVE, thats more like a COPY... > > so, given name1 and name2 I want to fill the name2 row with value from > name1 row... > > I have tried with UPDATE but after a couple of hours I have to admit > that I'm not able to do it :-( > > Can anybody help me ? > > val an UPDATE should do it, give us what you tried, and the error message(s) you got... -- Luuk |
| |||
| On 30 avr, 17:34, Luuk <L...@invalid.lan> wrote: > an UPDATE should do it, give us what you tried, and the error message(s) > you got... I thus have to show how unskilled I am with mysql... Here it is. The last one I tried is this : $sql = "UPDATE dbase SET field1= (SELECT field1 WHERE NAME='$old_name') WHERE NAME ='$new_name'"; $old_name contains 't1' and $new_name contains 't3' (I use PHP to send the request, through the mysql_db_query function. 1064: Erreur de syntaxe près de 'WHERE NAME='t1') WHERE NAME='t3'' val |
| |||
| On Wed, 30 Apr 2008 18:01:21 +0200, val <vlepage@aol.com> wrote: > On 30 avr, 17:34, Luuk <L...@invalid.lan> wrote: > >> an UPDATE should do it, give us what you tried, and the error message(s) >> you got... > > I thus have to show how unskilled I am with mysql... > > Here it is. The last one I tried is this : > > $sql = "UPDATE dbase > SET field1= (SELECT field1 WHERE NAME='$old_name') > WHERE NAME ='$new_name'"; > > > $old_name contains 't1' and $new_name contains 't3' > (I use PHP to send the request, through the mysql_db_query function. > > 1064: Erreur de syntaxe près de 'WHERE NAME='t1') WHERE NAME='t3'' SET field1= (SELECT field1 FROM what???? WHERE NAME='$old_name') -- Rik Wasmus |
| |||
| val schreef: > On 30 avr, 17:34, Luuk <L...@invalid.lan> wrote: > >> an UPDATE should do it, give us what you tried, and the error message(s) >> you got... > > I thus have to show how unskilled I am with mysql... > > Here it is. The last one I tried is this : > > $sql = "UPDATE dbase > SET field1= (SELECT field1 WHERE NAME='$old_name') > WHERE NAME ='$new_name'"; > > > $old_name contains 't1' and $new_name contains 't3' > (I use PHP to send the request, through the mysql_db_query function. > > 1064: Erreur de syntaxe près de 'WHERE NAME='t1') WHERE NAME='t3'' > > val time to study this page a bit more... http://dev.mysql.com/doc/refman/5.0/en/update.html -- Luuk |
| |||
| On 1 mai, 00:20, Luuk <L...@invalid.lan> wrote: > time to study this page a bit more...http://dev.mysql.com/doc/refman/5.0/en/update.html > Wonderful link ! from Rafi B, on this page : UPDATE jobs AS toTable, jobs AS fromTable SET toTable.job_type_id = fromTable.job_type_id, toTable.job_company_id = fromTable.job_company_id, toTable.job_source = fromTable.job_source, WHERE (toTable.job_id = 6) AND (fromTable.job_id = 1) Exactly what I was looking for. This page is like a collection of tricks, perfect for a beginner like me. Thanks ! val |
| ||||
| val schreef: > On 1 mai, 00:20, Luuk <L...@invalid.lan> wrote: >> time to study this page a bit more...http://dev.mysql.com/doc/refman/5.0/en/update.html >> > > Wonderful link ! > > from Rafi B, on this page : > > UPDATE jobs AS toTable, jobs AS fromTable > SET > toTable.job_type_id = fromTable.job_type_id, > toTable.job_company_id = fromTable.job_company_id, > toTable.job_source = fromTable.job_source, > WHERE > (toTable.job_id = 6) > AND > (fromTable.job_id = 1) > > Exactly what I was looking for. > This page is like a collection of tricks, perfect for a beginner like > me. > no, this is NOT a collection of tricks, this is the MANUAL... ;-) > Thanks ! > > val -- Luuk |