# Save query results as csv

**URL:** https://discuss.zetetic.net/t/save-query-results-as-csv/2343
**Category:** Uncategorized
**Created:** [September 7, 2017, 10:15pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343 "2017-09-07T22:15:20Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Joe\_Foley](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@Joe\_Foley](https://discuss.zetetic.net/u/Joe_Foley)
#### Post date: [September 7, 2017, 10:15pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/1 "2017-09-07T22:15:20Z")

</div>

Hi:  
I am utterly new to sql and am using DB Browser for SQLite  
My queries run fine but I cannot figure out how to export the results.  
When I select CSV export from the File menu all I get is the query rather than the manipulated data…  
I would truly appreciate someone explaining what I am doing wrong!  
Joe

---

<div class="post-metadata">

### Author: ![mmoore](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/mmoore/32/858_2.png) [@mmoore](https://discuss.zetetic.net/u/mmoore)
#### Post date: [September 7, 2017, 10:58pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/2 "2017-09-07T22:58:01Z")

</div>

@Joe_Foley

Thanks for posting. Let me preface my response with: _We (Zetetic) didn’t create DB Browser for SQLite_

I’m unsure if the desired functionality exists within the current interface but @justinclift would know for sure.

You could adjust your query to create a new table based on your current `SELECT` statement and then print out the newly created table as a CSV.

So take this example table:

![Sample_Books_Table](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/1X/2d60ae9fb2a6baeff429731ec0108bd0d97f5ed3.png)

Let’s say the query you want to export is:

```auto
SELECT title, author FROM books WHERE price > 10;

```

You could adjust it to be:

```auto
CREATE TABLE books_10 AS SELECT title, author FROM books WHERE price > 10;

```

Which would generate a table like:

![books_10_table](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/1X/effff64c15fe1a25e4036c126d87157139bf6c2c.png)

Then you can go to File → Export → Export Table(s) as CSV and select the newly created table generated by your query (books\_10) in the example here.

 ![Export_Table_As_CSV](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/1X/4abf49d488aee3f63a2e1b6e00ceb90a453bb659.png)

After exporting you’ll most likely want to run a query to discard the table that was created by the SELECT statement, something like:

```auto
DROP TABLE books_10;

```

Hope this helps!

Cheers,  
Micah

---

<div class="post-metadata">

### Author: ![justinclift](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/justinclift/32/89_2.png) [@justinclift](https://discuss.zetetic.net/u/justinclift)
#### Post date: [September 8, 2017, 10:56am UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/3 "2017-09-08T10:56:50Z")

</div>

Thanks @mmoore. 😃

@Joe_Foley The approach shown above will work, though there’s an easier way too.

In the “Execute SQL” tab, there’s a button in the bottom right for exporting the results:

![DB4S_csv_export1](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/1X/7b2c2535ec8762be69c7c210a74e6567d13d0695.png)

That pops up a small menu, the first choice in it is for saving the results to a CSV file:

![DB4S_csv_export2](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/1X/69a4cd26e833a3396f95151dc31555affb3d3e66.png)

![DB4S_csv_export3](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/1X/b217e6f7c50c8b61a1caf5f5a639156fdd3fadf0.png)

Note - make sure you select an appropriate “New line characters” option in that dialog, otherwise your results might end up looking like they’re all on one line.

In theory, I think that’s what you’re looking for. 🙂

As a thought, if you have other questions, feedback, want to file bugs (etc), then this here is the place you want:

> **[sqlitebrowser/sqlitebrowser](https://github.com/sqlitebrowser/sqlitebrowser/issues)**
>
> Official home of the DB Browser for SQLite (DB4S) project. Previously known as "SQLite Database Browser" and "Database Browser for SQLite". Website at: - sqlitebrowser/sqlitebr...

We’re generally pretty friendly. 🙂

---

<div class="post-metadata">

### Author: ![Joe\_Foley](https://avatars.discourse-cdn.com/v4/letter/j/85f322/32.png) [@Joe\_Foley](https://discuss.zetetic.net/u/Joe_Foley)
#### Post date: [September 8, 2017, 1:10pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/4 "2017-09-08T13:10:38Z")

</div>

Dear Micah & Justin:  
THANK YOU.  
I sam finally able to save my DB Browser results.  
FANTASTIC.  
I wish they would move that button from the bottom right to the upper  
left. Those who know what they are doing will find it but those of us lost  
in the woods would not think to look away from all of the drop down menus.

So if you guys ever need a kidney or a lung or a pint of blood, just ask.  
I’d offer you the brain but its not good for much.

HAVE A GREAT DAY.

---

<div class="post-metadata">

### Author: ![justinclift](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/justinclift/32/89_2.png) [@justinclift](https://discuss.zetetic.net/u/justinclift)
#### Post date: [September 8, 2017, 3:44pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/5 "2017-09-08T15:44:49Z")

</div>

> [@Joe\_Foley](#):
>
> I wish they would move that button from the bottom right to the upper left.

Ahhh, good point. I’m so used to it in the bottom right that I’ve never really thought about it.

Just added an item about that to our issue tracker:

> <https://github.com/sqlitebrowser/sqlitebrowser/issues/1122>
>
> \### Details for the issue
> 
> An UI optimisation has been suggested by a new-to-S…QL user here:
> 
> &nbsp; &nbsp; https://discuss.zetetic.net/t/save-query-results-as-csv/2343/4
> 
> In the issue discussion thread there, they were looking for the \`Execute SQL\` tab's "Export to CSV" button in the top row, where all of the other buttons are.
> 
> It might be decent idea to move it there, so that new users find it easier. It shouldn't be much/any problem for more experienced users to locate it's new location. :smile:
> 
> \#### I'm opening this issue because:
> 
> \- \[x\] DB4S has another problem
> 
> \#### I'm using DB4S version:
> 
> \- \[x\] 3.10.0

No idea how it’ll go (I can see both pro’s and cons to moving it), but at least it’s on the radar now. 🙂

---

<div class="post-metadata">

### Author: ![justinclift](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/justinclift/32/89_2.png) [@justinclift](https://discuss.zetetic.net/u/justinclift)
#### Post date: [September 20, 2017, 4:20pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/6 "2017-09-20T16:20:00Z")

</div>

> [@Joe\_Foley](#):
>
> I wish they would move that button from the bottom right to the upper left.

Good news Joe. That button has now been moved. The change isn’t in our just-released-today version 3.10.1. But it is in our nightly builds, and will be in the official 3.11.0 release (when that comes out). 😄

---

<div class="post-metadata">

### Author: ![Benjamin\_Labarthe-Pi](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/benjamin_labarthe-pi/32/1478_2.png) [@Benjamin\_Labarthe-Pi](https://discuss.zetetic.net/u/Benjamin_Labarthe-Pi)
#### Post date: [October 5, 2020, 4:11pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/7 "2020-10-05T16:11:31Z")

</div>

Guys, thank you sooooo much! I’ve been struggling for an hour until I found your answer. That’s awesome and answsers perfectly my questions. If I may, I would only have one more question. I am based in France and when I do the csv export from DB Browser, I get wrong characters displayed on the csv. If anyone has an idea how I could fixed that… thank you again, so much!

---

<div class="post-metadata">

### Author: ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)
#### Post date: [October 5, 2020, 8:11pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/8 "2020-10-05T20:11:36Z")

</div>

Hi @Benjamin_Labarthe-Pi

If you wish to report an issue regarding the behavior within DB Browser for SQLite, that would be best directed to their GitHub Issues page [here](https://github.com/sqlitebrowser/sqlitebrowser/issues). Zetetic does not develop or maintain DB Browser for SQLite, rather we develop both SQLCipher and Codebook. If you are experiencing an issue specific to SQLCipher, please feel free to post that separately [here](https://discuss.zetetic.net/c/sqlcipher). Thanks!

---

<div class="post-metadata">

### Author: ![Benjamin\_Labarthe-Pi](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/benjamin_labarthe-pi/32/1478_2.png) [@Benjamin\_Labarthe-Pi](https://discuss.zetetic.net/u/Benjamin_Labarthe-Pi)
#### Post date: [October 6, 2020, 2:14pm UTC](https://discuss.zetetic.net/t/save-query-results-as-csv/2343/9 "2020-10-06T14:14:54Z")

</div>

that’s noted! thanks again
