Oracle : Update query example

 

UPDATE table_name
SET VARIATION = ‘Apple’
WHERE VARIATION like ‘Course aseem%’

 

Those with a SqlServer background will be familiar with the UPDATE .. FROM syntax.
For example (totally made up)

   1: update employee_bonus
2: set bonus = 0
3: from employee_bonus b
4: inner join employees e on b.employee_id = e.employee_id
5: where e.bonus_eligible = 'N'

Those who transitioned from SqlServer to Oracle might find the absence of the UPDATE FROM a significant loss.  The best Oracle alternative that I know of is as follows.

   1: update (select bonus
2: from employee_bonus b
3: inner join employees e on b.employee_id = e.employee_id
4: where e.bonus_eligible = 'N') t
5: set t.bonus = 0

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s