user2827435 user2827435 - 1 year ago 66
SQL Question

How to increase the MySQL variable count

Friends, in my project I have a variable named bill_number; every time the PRINT bill button is clicked I want to increase the value of bill_number by one in the database. Please help me as soon as possible.

set @bill_number = @bill_numer+1;

This is the query I've tried before but it's not working.

Answer Source

I would advise to maintain a table containing all the counts (like bill_number) and then use SELECT FOR UPDATE to fetch and update the count on the events. It will increase the maintainability.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download