Let suppose I have a query that runs multiple times because it is in a while loop which inserts data into a table.
INSERT INTO <table>( psuiKey, group_id) VALUES ('54ds8a784daEd','1');
The problem is when two users from different computers add data at same time. So what is happening is user 1 adds data to the table to looks like this:
psuiKey group_id 54ds8a784daEd 1 54ds8a785daEd 1
and at the same time user 2 adds data where
group_id is 2, but the data looks like this:
psuiKey group_id 54ds8a784daEd 1 54ds8a785daEd 1 54ds8a786daEd 1 54ds8a787daEd 1
psuiKey group_id 54ds8a784daEd 1 54ds8a785daEd 1 54ds8a786daEd 2 54ds8a787daEd 2
So in short if two users add the same data at same time so
group_id is not changing when I find max
SELECT MAX(group_id) + 1
So SQL can't able to update it when two users add data at the same time.
Note I cant use
group_id as primary key and I also use
So any help would be helpful!