Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update Table Column From Another Column

 
Mittal Swati
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I was looking for MYSQL query that can update one of column value from other column value "based upon some condition".
My table looks like --


I want to update END_YEAR column value.
Filter is --- END_YEAR value should be same as START_YEAR value if REF_ID is not duplicate otherwise END_YEAR value should be next START_YEAR value.

query OUTPUT should be like that ----




Thanks in Advance !

 
Paul Clapham
Sheriff
Posts: 21579
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It isn't possible for SQL queries to update a database table. However perhaps you just needed to see a computed value as one of the columns in your result? You can certainly do that, supposing of course that the condition you're basing the calculation on is something that can be evaluated from other data in the tables you're querying.

Although your example is sort of confusing -- your description of your requirements refers to several columns which we can't see in your query.
 
Mittal Swati
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul.

Yes my requirement is little complicated.

Anyway I am working on query let see if get any success in that.


 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic