mysqli - MySQL update a field with an incrementing variable -


i have table named 'textile_events' in 1 of databases.

mysql> describe textile_events;  +-------------+--------------+-----+---------+----------------+ | field       | type         | key | default |          | +-------------+--------------+-----+---------+----------------+ | id          | int(11)      | pri | null    | auto_increment | | token       | varchar(20)  |     | null    |                | | reg_time    | datetime     |     | null    |                | | eid         | varchar(20)  |     | null    |                | | fname       | varchar(20)  |     | null    |                | | lname       | varchar(20)  |     | null    |                | | paid        | varchar(10)  |     | null    |                | | seq_no      | int(11)      |     | null    |                | +-------------+--------------+-----+---------+----------------+ 8 rows in set (0.00 sec)  mysql> select count(*) textile_events;  +----------+ | count(*) | +----------+ |     9325 | +----------+ 1 row in set (0.00 sec)  mysql> select count(*) textile_events eid = 'headsup' ;  +----------+ | count(*) | +----------+ |     2553 | +----------+ 1 row in set (0.01 sec) 

'seq_no' field introduced above table yesterday.

now, need assign incrementing number 'seq_no' field 'headsup' events paid field equal 'paid'.

in other way, looking this,

$i = 250 while( true ):     $i++     update textile_events set 'seq_no' = $i          eid = 'headsup' , paid = 'paid' endwhile; 

how assign incrementing number newly introduced field recods satify given condition?

what available options , efficient way accomplish this?

are looking this?

update textile_events e,        (select @n := 249) m    set e.seq_no = @n := @n + 1      e.eid = 'headsup' , e.paid = 'paid' 

sqlfiddle


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -