2

I need to integrate my e-commerce with the local system.

I need to export specific fields from multiple tables of my database into a csv file.

I need from TABLE jos_virtuemart_products those fields product_sku , product_in_stock , low_stock_notification , product_length , product_width , product_height , product_weight

then

I need from TABLE jos_virtuemart_products_en_gb those fields purodct_name , product_s_desc

then the out put csv file should me imported to another database table that has all those fields from the others 2 table above.

Is it possible to be ran by mysql command in the linux command line? or I will have to figure out other way?

Have some one been in this situation?

Which is the best way to do this itegration?

3 Answers 3

1

If you can write a query for what you want, you can use SELECT ... INTO OUTFILE to write it to a CSV file on the server. Add FIELDS TERMINATED BY to set the separator to ',' as the default is to use tabs.

http://dev.mysql.com/doc/refman/5.5/en/select-into.html

Sign up to request clarification or add additional context in comments.

19 Comments

Hi Joshua, I did end up with this steps: 1.TEE Results.csv SELECT product_sku FROM jos_virtuemart_products; SELECT product_weight FROM jos_virtuemart_products; NOTEE
sorry got a little massed up with this comment, what i would like to say is that i create a file with this command TEE Results.csv SELECT product_sku FROM jos_virtuemart_products; SELECT product_weight FROM jos_virtuemart_products; NOTEE and then ran with this command: mysql -u root -p -h localhost table_name < tee.test and after it printed on my screen the columns it said that outfile is desable and couldn't create the file.
Okay according to [link]dev.mysql.com/doc/refman/5.1/en/mysql-commands.html[/link] I removed the ending line NOTEE so the out put now didn't show the outfile desable but either created a file???
Okay now I did it with SELECT ... INTO OUTFILE and it seems like this SELECT product_sku, product_in_stock, low_stock_notification, product_length, product_width, product_height, product_weight INTO OUTFILE 'jos_virtuemart_products.csv' FIELDS TERMINATED BY ',' FROM jos_virtuemart_products; but I need to get data from multiple tables and mixe them in the same out put file did you understand?
You need to join two tables together, something like: SELECT * FROM jos_virtuemart_products AS a, jos_virtuemart_products_en_gb AS b WHERE a.product_sku=b.product_sku. You can also define your new table and move the data into the new table directly in MySQL: INSERT INTO newtable SELECT …
|
0

If you can produce a query that results in the table for the new system (probably using some kind of join), you can export THAT to a csv file.

Comments

0

I did solve my problem with help of @Joshua Martell and what has openned my eyes was this post PHP mySQL, Joining More than Two Tables Together with Similar IDs? with the answer from @Jatin Dhoot thank y'all!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.