MySQL Forums
Forum List  »  MyISAM

orderid with point of sale application
Posted by: Christian Johansson
Date: April 19, 2006 04:04PM

I need help with a problem with transactions id.

table: restaurant
id, restaurant, orderid,....

table: orders
id, orderid, total,....

I need to select the orderid from restaurant and place it in the table "orders" and then orderid+1 i the table restaurant.

Example:

Someone ordered a burger and i select a new orderid for the transaction from the the table "restaurant" and place the orderid in the table "orders" after that i need to update the new value in table "restaurant" so the next order will be ok.

The problem is if we have multiple users that make transactions and one order is fast or different speed so they will take the same orderid. How can i prevent that?

Today i use:
select orderid from restaurant;
update orders set orderid=orderid+1;

Can i make it in the same sql or look rows or something?

Best regards.



Edited 1 time(s). Last edit at 04/19/2006 04:05PM by Christian Johansson.

Options: ReplyQuote


Subject
Views
Written By
Posted
orderid with point of sale application
2883
April 19, 2006 04:04PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.