Manish Goyal
Manish Goyal

Reputation: 101

how to integrate new data with existing data in a column in mysql?

i want to integrate data with exiting data in a column in phpmyadmin.

for example i have a table which has a column (ticket_number).

And its exiting value is 234 and want to add '1' before 234 so that the value will be 1234. this below written code not working for this.

UPDATE ticket
SET `ticket_number`+= '1';

thanks in advance.

Upvotes: 2

Views: 105

Answers (3)

DarkAjax
DarkAjax

Reputation: 16223

Try using CONCAT:

UPDATE ticket
SET ticket_number = CONCAT(1,ticket_number)

Because if you add up the "1" directly you'll get 235 not 1234...

Upvotes: 6

Michael Dunlap
Michael Dunlap

Reputation: 4310

Probably something like this:

UPDATE ticket
SET ticket_number = '1' + ticket_number

MySQL doesn't understand +=

Upvotes: 3

James McDonnell
James McDonnell

Reputation: 3710

Because your data is probably stored as an integer, you would need to add 1000 not 1.

You could provide some more information about the field type.

Upvotes: 2

Related Questions