php - Mysql update a row with another row value in same table -


i have table. want update 5th row 10th row values same table. example:

slno   name quali   exp 1        x   b.e     2 2        y   bsc     3 3        z   b.a     1.5 4          msc     2 5        b   mba     5 

here want update second row value of 5th row.

here current query:

    update table        set name=(select name table slno='5'),                quali=(select quali  table slno='5'),                exp=(select exp table slno='5')        slno='3'; 

this working fine ... if there more 20 columns becomes laborious write query way, because each column have include sub-query... there other way write query update whole row values other row in same table?

use self-join multiple table update syntax:

update `table` t1 join `table` t2 on t2.slno = 5 set    t1.name = t2.name, t1.quali = t2.quali, t1.exp = t2.exp  t1.slno = 3 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -