Page 1 of 1

Select only on record?

Posted: Tue Feb 02, 2010 1:31 pm
by gertrudis
Hi to all.

I have a table with 13g record, and they're 20 user selecting record from that specific table.

Some time when they are selecting record, the same record appear in 2,3,4,5 user at the same time.
I neet something that when a record is select it for one user could not be select from other at the same time, but with giving lock record or any thing like that.

there is something in the select-sql that could prevent this to happens?
this is my sql-selete command:

$result = mysql_query("SELECT * FROM customer WHERE isnewclient='NL' and iduser='') ", $link);
immediately i update the record:
$phone_number=$row[1];
$result = mysql_query("UPDATE customer SET iduser='$username' WHERE phone_number='$phone_number'") or die(mysql_error());
but any way more than 1 people is getting duplicate
thanks in advance

Re: Select only on record?

Posted: Wed Feb 03, 2010 4:19 am
by aravona
Bit hard to understand you but if I'm understanding correctly:

You're wanting to select a record for 1 user only, but its bringing up records from other users as well ?

Re: Select only on record?

Posted: Sun Feb 21, 2010 6:22 pm
by gertrudis
I have 20 user in different computer, all of then accessing the same database.

Every things is OK, but once a while 2 or more user get the same record in they're screen, i need to avoid that one record from db appear in more than 1 user.

I have try select for update but when i try to update all user freeze.

Re: Select only on record?

Posted: Sun Feb 21, 2010 9:47 pm
by mikosiko
gertrudis wrote:I have 20 user in different computer, all of then accessing the same database.

Every things is OK, but once a while 2 or more user get the same record in they're screen, i need to avoid that one record from db appear in more than 1 user.

I have try select for update but when i try to update all user freeze.
You can find information about locking mechanism and strategies here for Innodb:
http://dev.mysql.com/doc/refman/5.0/en/ ... s-set.html

and here:
http://dev.mysql.com/doc/refman/5.0/en/ ... modes.html

your final goal (don't allow the user to see records being seeing or used for others users) is highly unusual in database concepts and implementation

Re: Select only on record?

Posted: Wed Mar 24, 2010 6:41 pm
by gertrudis
thanks a lot mikosiko
Change table engine to innodb works.