I Have a MYSQL 5.0 DB with two tables that need to be updated with a bulk upload from csv file. I need an infile SQL query that we can run.
The tables are:
BRAND
field: Id :int
field: Name: varchar
field: path: varchar
field: Description: mediumtext
Example row:
1 Acura Null Null
MODEL
field: ID :int
field: Brand :int
field: Category :int
field. Name :varchar
field: Description :mediumtext
Example row:
1 1 1 NSX Null
CATEGORY
field: Id :int
field: Parent :int
field: Name :varchar
field: Path :varchar
Example row:
1 Null Cars car
The CSV file has the format (with two example rows):
Category,Brand,Model
Cars,Acura,NSX
Motorcycles,Harley Davidson,Fat Boy
The script needs to:
1. Add new models to existing brands
2. Add new brands
3. Add new models to new brands
4. Add a new "empty" model to each new brand (with Null value in Name field and same category as the other models from that brand)
We will be adding to the csv file and running the script a few times a week, which is why it needs to check for existing data.