mysql - Update a column based on its value -


to update table use this:

update `table` set column = value column = value 

is there way update column value? example:

table 'test' has 2 columns called 'one' , 'two'.

i'll set them: 'one' 10, , 'two' 20, , wish update columm have value 10, variable, , can't know wich column is.

thanks

you'd have query table first:

select * mytable col1 = 10 or col2 = 10

then, you'll need server-side code (like php, ruby, python, etc) determine column has needed value, , can build new update query based on that:

update mytable set col1 = 20

however, can't think of scenario efficient way of managing data. may want reconsider how database designed.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -