Galih Leo
Galih Leo

Reputation: 55

how to update a record in the table to insert a comma and a value and its value in sql

i have a table school with fields : no.reg and item like below :

table school

no.reg= A
item  = book.
no.reg= B
item  = chair.

i want to insert record city with comma where no.reg = A the result :

no.reg= A
item  = book , ruler, eraser.
no.reg= B
item  = chair

how to create a query for that ??

Upvotes: 1

Views: 36

Answers (1)

Xedni
Xedni

Reputation: 4695

update school
set item = 'book, ruler, eraser'
where [no.reg] = 'A'

or if you want to append a certain value to what exists already, just concatenate what you want

update school
set item = item + ', ruler, eraser'
where [no.reg] = 'A'

Upvotes: 1

Related Questions