List:General Discussion« Previous MessageNext Message »
From:haidarpesebe Date:April 4 2012 11:30am
Subject:Re: migrate existing data each additional product
View as plain text  
Thanks for quick reply. And also thank you very much for the information.
Best regard

------Original Message------
From: Johan De Meersman
To: Albahar Uya
Cc: MySQL Lists
Subject: Re: migrate existing data each additional product
Sent: Apr 4, 2012 17:33

----- 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, though.

/johan

-- 
Bier met grenadyn
Is als mosterd by den wyn
Sy die't drinkt, is eene kwezel
Hy die't drinkt, is ras een ezel


Sent from my BlackBerry® smartphone
Thread
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