Jump to content

Check duplicate before insert query


dextrocity

Recommended Posts

Well theres a few ways but to do it simply....

 

Select COUNT(*) FROM database WHERE username_column = $username_variable

In addition to that

 

$sql = "SELECT COUNT(*) FROM database WHERE username_column = $username_variable";
$result = mysql_query($sql);
if (mysql_num_rows($result) > 0)
{
//username taken
}
else
{
//proceed
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.