Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

1) I've got a 30K row table. 2) When I run a long, 50-line query on that table, a GROUP function reduces the number of rows to 7K. 3) I want to export the grouped 7K rows as a new table, or save them as a CSV.

When I attempt to export, instead of getting the grouped 7K rows, I get the old, pre-query 30K rows.

What am I doing wrong, and what should I be doing?

NOTE: I'm not a coder, so I'd really appreciate a solution that just used the PHPMyAdmin GUI.

Thanks!

share|improve this question

3 Answers 3

  1. Execute your sql query in the SQL tab of phpMyAdmin.

  2. After execution, scroll down the page and look for “Query results operations”

  3. Click “Export” link from the above and you will get the page to export all the results of the queries to desired format. That’s it.

share|improve this answer
    
Very simple, don't know why I haven't seen it there in the past! –  Nicholas Decker Mar 31 at 20:38

Instead of the export button at the top of the GUI, use the one at the bottom, within the "Query results operations" box. That is the one you want.

Export button

share|improve this answer
    
I had uploaded a picture here as well - wonder where it went. P.S. - if this solved your problem, please mark it as the correct answer. –  Sudipta Chatterjee Aug 12 '11 at 17:31
    
Thanks! In the current interface there's yet another incorrect "export" button, right about the "query results operations" box. The screenshot is helpful. –  octern Feb 7 '13 at 19:43

You've already got the query? You can insert into a new table using another query's results

Looks like the steps you need:

  1. Create the new table with all the columns.
  2. INSERT INTO newTable (field1, field2, field3) SELECT field1, field2, field3 FROM otherTable GROUP BY field1

Adjust for your 50-line query.

share|improve this answer
    
Thanks!Let me see if I understand... (1) create newtable (2) oldtable has about 60 columns, and all are being used, so... INSERT INTO newtable * SELECT * from oldtable (3) do i place your INSERT INTO code at the end of my existing query? –  grape Aug 11 '11 at 23:18
    
You put the INSERT INTO before your query. It works just like a normal INSERT except instead of providing "VALUES (rowColumn1, rowColumn2, rowColumn3)", you're providing the results of the SELECT instead. –  Reece45 Aug 12 '11 at 15:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.