MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Johan De Meersman Date:April 4 2012 10:33am
Subject:Re: migrate existing data each additional product
View as plain text  
----- Original Message -----
> From: "HaidarPesebe" <haidarpesebe@stripped>
> I asked for help, how to order that each time I add an item then the
> item number in column 1 move to column 2, column 2 moves to the
> column 3, column 3 to 4 and so on.
> product     | 1 | 2 | 3 | 4 | total
> [...]

What a most peculiar thing to do :-)

You can't have - correction: I don't think you can have column names that start with a
digit, so I'll conveniently call them c1 and so on.

An update statement is processed in order, so this should work:

UPDATE <yourtable> SET c4=c3, c3=c2, c2=c1, c1=<newvalue>, total=c1+c2+c3+c4
WHERE <uniqueidentifierthings>;

I would strongly question whether there's no better way to design whatever you're doing,


Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel
migrate existing data each additional productHaidarPesebe4 Apr
  • Re: migrate existing data each additional productJohan De Meersman4 Apr
Re: migrate existing data each additional producthaidarpesebe4 Apr