• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

select cum update

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
How can i update the data while getting it.

i.e.
i am selecting the data from emp table , while getting only
i have to add 1000 to deptno=10

how can i?
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by raj baig:
How can i update the data while getting it.



Assume that you are looking UPDATE statement with SELECT to update records in a table based on another table or same table value.

SQL: UPDATE Statement

is this what you looking for?
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can perform an update into using a select, but I think he's talking about modifying the data coming from the select statement artibitrarily. In that case you have to create a new statement to the database an execute an UPDATE sql command separately from your SELECT query. That's the cleaner/better way to do it anyway.

For example, you may need to make changes to a dozen records, rather than 12 separate update calls, mark the records during the select you need to change and then update them all in a single update statement after all the records have been read.
 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Saif and Scott
 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi saif,
The links shows updating & selecting , but i want
selecting & updating.

suppose in my emp table deptno 10 employees sal =2000.

i want to get the employee information, while retrieve add 1000 to dept 10.
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by raj baig:

but i want selecting & updating.




Scott Selikoff reply:

In that case you have to create a new statement to the database an execute an UPDATE sql command separately from your SELECT query. That's the cleaner/better way to do it anyway.

 
reply
    Bookmark Topic Watch Topic
  • New Topic