1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

test/check to see if # is unique

Discussion in 'Software Development' started by jbdog4life, Apr 8, 2010.

Thread Status:
Not open for further replies.
  1. jbdog4life

    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.
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    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.
     
  3. phyrtech

    phyrtech

    Joined:
    Mar 22, 2010
    Messages:
    39
    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.
     
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 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/915569

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice