mardi 5 mai 2015

SQL update row depending on other values in same row

I have a table similar to this:

Index    Name       Type
--------------------------------
1        'Apple'   'Fruit'
2        'Carrot'  'Vegetable'
3        'Orange'  'Fruit'
3        'Mango'   'Fruit'
4        'Potato'  'Vegetable'

and would like to change it to this:

Index    Name       Type
--------------------------------
1        'Apple'   'Fruit 1'
2        'Carrot'  'Vegetable 1'
3        'Orange'  'Fruit 2'
3        'Mango'   'Fruit 3'
4        'Potato'  'Vegetable 2'

Any chance to do this in a smart update query (= without cursors)?

Aucun commentaire:

Enregistrer un commentaire