How to See if an Entry Exists in MySQL

The MySQL "exists" statement tells you if an entry already exists in the database. You use this statement to avoid inputting duplicate content into your database. You must determine the field you want to use to verify the entry exists. For instance, you use the email address to only allow one account for each email address stored in the database.

Instructions

    • 1

      Open the Query Browser software from the Windows program menu on your MySQL database server.

    • 2

      Log in to the database using your username and password. Click the "File" menu item and select "New" to create a new MySQL code editor window.

    • 3

      Type the following MySQL code to determine if a record exists:

      SELECT customername FROM customers
      WHERE EXISTS (SELECT * FROM customers
      WHERE email = 'mymail@email.com');

      This code determines if a customer exists using the email field criteria. You can use any field name in the sub-query to determine duplicate records.

    • 4

      Click the "Execute" button. If a record returns, the record already exists in the database.

Related Searches:

References

Comments

Related Ads

Featured