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

    Unhappy Unanswered: Inserting records

    I know this posting needs to be in the mySQL forum but I did not receive any help there

    I have a text file with 100s of "INSERT" statements. Some of the records already exist in the table. How do I tell mySQL to ignore entries that are already there and add those that are new. I am using PHPmyAdmin and it coughs at the first record (since it already exists) and quits

    Thanks in advance.

  2. #2
    Join Date
    Mar 2004
    you can use php and have it check for and id maybe so it will spit out what you need and copy and paste it onto phpmyadmin. hopefully that 100 insert statements were generated using variables and if so you can use those variables here

    for ($a=1; $a<100; $a++){
    $conn = connection string
    $db = db info
    $sql = "SELECT id FROM table WHERE id = $a";

    if(!$sql) {
    mysql_query($sql, $conn);


    basically the code says to run the insert statement if the id or whatever it is you are checking for doesn't existing which will eliminate your record already exist error

    hope that helps or gives you an idea

  3. #3
    Join Date
    Jun 2003
    Im almost positive there is an sql statement for this. try searching on google, or these forums.
    Mr. Lars

Posting Permissions

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