test/check to see if # is unique

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

jbdog4life

Thread Starter
Joined
Dec 8, 2009
Messages
17
I have an add/edit program I've written and I'm trying to find an example of how to test/check an Account Number that a person enters in a textbox to the database(SQL) to make sure it is unique. I've been searching and haven't had any luck. Any Advice? Thanks.
 

OBP

Joined
Mar 8, 2005
Messages
19,896
It would help if we knew which programming language you are using.
If you set the SQL Table Account Number Field to Unique or "No Duplicates" it should achieve the same thing.
 
Joined
Mar 22, 2010
Messages
39
It would help if we knew which programming language you are using.
If you set the SQL Table Account Number Field to Unique or "No Duplicates" it should achieve the same thing.
This is the proper way to do it. ^

Another way is to query the table to find if the value already exists:

SELECT count(*) from `table` WHERE `id`=23 LIMIT 1;

This returns 1 if the column `id` already has 23 in a row and 0 if it does not.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top