Check Existing Record

Joined
Jan 6, 2012
Messages
5
Programming Experience
Beginner
How to Check if their is an Existing Record in my MySQL Database so that their is now same record in my Database.
 
If you want to see if a record already exists, simply query the table with the params that would you have if you were to insert the record.

For example, if you have a username table (UID, FName, LName) and you want to see if a user exists (SmithJ, John, Smith)
Select * From Usernames Where UID = 'SmithJ' And FName = 'John' And LName = 'Smith';

Or if you want to just see if the username exists it's simply:
Select * From Usernames Where UID = 'SmithJ'

In both cases, if you get a record back then it already exists, and if it doesn't exist then the record count returned would be 0 (zero).
 
Back
Top