Click here to Skip to main content
15,902,114 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I'm new to mongodb and want to export collection (table) to csv file. I want to write the below sql server query in mongodb.

<pre lang="SQL">SELECT Id, Name, Company FROM CompanyDetails WHERE Company in ( 'Monte Node Bell', 'Amdocs') ORDER BY Company </pre>

and then export the data to csv file with field name as column headers.

I have no clue beyond
<pre lang="Javascript">db. Table1.find() </pre>
Please help.
Posted
Updated 30-Oct-14 23:18pm
v4

1 solution

Once you have your csv file, read this : http://docs.mongodb.org/manual/reference/program/mongoimport/[^]

Edit:
If you want to export from mongodb then read this : http://docs.mongodb.org/manual/reference/program/mongoexport/[^]
 
Share this answer
 
v2
Comments
GoneBump 31-Oct-14 5:17am    
Hi, I don't want to import the data but to expprt it in specific format like the sql queries output.
Mehdi Gholam 31-Oct-14 5:19am    
Read the updated solution.
GoneBump 31-Oct-14 5:27am    
Thanks, but what about the query? How to get the sql query results in mongodb?
Mehdi Gholam 31-Oct-14 5:43am    
Mongodb does not have a sql query interface it uses it's own style.
GoneBump 31-Oct-14 6:19am    
That is the thing which I dono. Could you help?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900