var sidebar_align = 'right';
var content_container_margin = parseInt('350px');
var sidebar_width = parseInt('330px');
Best SQL practice on UNIQUE field
I have a batch script that a CSV file to a Mysql database.
I have a unique row named CODE in my mysql table, and I was wondering what was the best thing to do:
Parse the entier csv file and:
- Issue a COUNT(*) to know if the CODE is already in the database. If not, issue the insert command.
- Just issue the INSERT command. Since it is unique, no duplicates will be made.
We are talking about 500 lines, every hour. I was wondering if it was easier to issue the count(*) and insert, or just insert and let mysql return an error if the code is already in the table ...
Thanks in advance,
Last edited by oldunis; 10-02-2009 at 02:43 PM.
You could also use REPLACE.
Antonis Adamakos @ FuzzFree :: Fully Managed Web Hosting, Development, Online Marketing
By Goldfiles in forum Programming Discussion
Last Post: 02-11-2008, 05:13 PM
By ti_nhatrang in forum Programming Discussion
Last Post: 07-20-2007, 10:22 AM
By Myriad in forum Programming Discussion
Last Post: 01-26-2006, 01:26 PM
By deet in forum Web Design and Content
Last Post: 08-15-2004, 08:10 AM
By kneuf in forum Programming Discussion
Last Post: 03-26-2003, 12:39 AM