Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004

    Question Unanswered: Data insertion without duplicates? help


    I have another problem.
    I have a data insertion form for my database witch inserts a clients payment details for a selected month.

    How can I check if the selected month in the form is already in the table for the respective client so it can't be added any duplicates. For example if a client has payment details for January, the form checks the details and restricts adding for that month again.

    Thank you in advance for your help.


  2. #2
    Join Date
    Aug 2006
    San Francisco, CA
    First you need to know who the client is and which month they are trying to add. This information could be sent through either the GET() or POST() to the current page

    Use this information to query the database to see if the client has a payment for the particular month

    if results != 0 then
    there is already a month and do not add
    add the month

  3. #3
    Join Date
    Jan 2005

    insert ignore

    set both fields as keys
    then use the INSERT IGNORE statement in the place of INSERT. if there is an error (duplicate) MySQL will just ignore it instead of throwing an error.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts