Results 1 to 2 of 2

Thread: help with a conditional INSERT statement

  1. #1
    Join Date
    Oct 2005
    West Chester, PA

    help with a conditional INSERT statement

    I have a zip code table which I downloaded from a website in Excel format. I need help on an INSERT script which will look at the Excel table (Imported into Access) and INSERT the row from the Excel table into local Zip Code table unless the entry already exists in the Local table.

    Would it be something like "INSERT INTO ZipCodes (zip,city,state,area_code) VALUES (excel.zip,excel.city,excel.state,excel.area_code) IN excel;'?

    if I set the Primary Key to zip, then it should ignore the entries that already exist right?
    Woohoo! It wor... er, wait, no it doesn't...
    PHP Coding Standard PHP Namespaces

  2. #2
    Join Date
    Aug 2004
    Sounds reasonable. I don't know, however, what exactly Access will do if you try to insert a duplicate key: just ignore it or raise an error.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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