Import /Export csv file into mysql using php

If you are in trouble due to importing csv data into your mysql database and if you want do some operation on your csv data but you face limitation of csv then this post is for you because in php importing data from csv is very tedious work. And in csv operations on data are also difficult to handle.
MS Excel helps in csv data management and operations but it requires knowledge of excel functions. I had faced this trouble in our project where we needed to import csv file that contained product data with magento dataflow import export profile, but our product.csv file was not in proper format. If we do changes in csv file manually we require a lot of time so, we finally decided to first import csv data in mysql database and then with help of sql query make all the changes into data then we export data. We spent a lot of time to get this to work.  That’s why I am uploading this code to help people who are in are having same problems as we had with importing and exporting data into mysql. This code will also help magento users who do not have properly formatted csv files. For that first import data into mysql with given script then create a new table with mysql query as per reqired format then export your mysql data into csv format.

downlaod script for import/export csv into mysql

Update Join in Mysql Query

Its very difficult to write and ambiguous task to write a select query when doing update.

so mysql provide us Update Join Query

its syntax is quite different than sql and oracle to write update join


update your_table your_table alias
inner join your_inner_join_table your_inner_join_table_alias
ON your_table.primary_id = your_inner_join_table.co_relational_primary_id
set your_table_update_field = value
where <condition> 


Update specials s inner join products p
on p.products_id=s.products_id
set s.specials_new_products_price = p.products_price-2
where p.products_price < s.specials_new_products_price

i hope this will help you
best of luck