0

my homework require me to execute those queries and show the result. Thing is I can export the table into CSV or excel just fine, but the TA require me to somehow show the exact command line that give it the table.

Is there some statements like log or something to do that?

Rozen
  • 139
  • 1
  • 2
  • 14
  • I find a pencil and paper can give good results. –  Nov 20 '13 at 19:37
  • haha, I did try to do that. Thing is my class suppose to use Oracle and spool would be the command used to output into text. I used mysql instead and there is no equivalent command. I did checked and found the similar answer to yours which is given below. I just ask again to make sure that there is indeed no equivalent of spool on mysql side. – Rozen Nov 20 '13 at 19:43
  • Nope, no spool command equivalent in MySQL. The closest is the `>` symbol for command line. Possible duplicate – Kanishka Ganguly Nov 20 '13 at 19:48

1 Answers1

0

You can use the mysql command from the shell with the -v option, it will display the query followed by the results:

$ mysql -v -e 'select * from barmar_test';
--------------
select * from barmar_test
--------------

+-----------+-----------+---------+------+------+---------------------+------+
| username  | timestamp | partner | e    | en   | t                   | ttx  |
+-----------+-----------+---------+------+------+---------------------+------+
| foo       | NULL      | abc     | N1   | NULL | 2013-07-03 23:27:47 | NULL |
| foo       | NULL      | abc     | 1    | NULL | 2013-07-03 23:25:12 | NULL |
| NULL      | NULL      | abc     | 12   | NULL | 2013-07-03 23:25:12 | NULL |
| foo       | NULL      | abc     | NULL | NULL | 2013-08-30 15:01:39 | NULL |
| foobarbaz | NULL      | abc     | NULL | NULL | 2013-09-02 13:04:00 | NULL |
+-----------+-----------+---------+------+------+---------------------+------+
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • This is the closest thing i can get, ty, really appreciate it – Rozen Nov 20 '13 at 20:01
  • Since I am using windows, what I did is that I just open mysql command line client, then use db, and desc table would show the thing, but then another question arrive... how do I copy and paste or output what I type in this console into text? I GOT IT, IF ANYONE ELSE GOING TO CHECK THIS POST, THEN http://stackoverflow.com/questions/4243610/export-sql-query-to-txt-using-command-line – Rozen Nov 20 '13 at 23:05
  • You should be able to use the mouse to copy and paste from the Command Prompt window into WordPad – Barmar Nov 20 '13 at 23:07
  • scratch my link away, it prob work for linux but not windows. Barmar, I could not use the mouse to drag and select or copy at all. Well, one good thing is I can select everything and paste EVERY SINGLE thing and paste in note pad.. I guess I can work it out from there. REALLY APPRECIATE YOUR HELP! – Rozen Nov 20 '13 at 23:12
  • Sorry, I'm a Mac/Linux user, I can't help you with Windows. Isn't there an Edit menu in the Command Prompt window, with Copy and Paste commands? I'm sure if you google "copy from cmd.com" you should be able to find instructions -- SO is not a place to learn how to use basic system programs. – Barmar Nov 21 '13 at 00:38
  • Yes, there is copy and paste, but for some reason they don't let me select specific lines or whatever I want. The only way I can select is select all, weird huh? But select all work fine for me, at least I can get it out and paste into notepad. I'm on the roll, never know working with commandline is much faster than workbench haha. – Rozen Nov 21 '13 at 02:38
  • u are right, I'm too quick to ask for help, should do research more, indeed in quick edit mode, I can drag a box and copy that selected part. I'm grateful for your help, barmar. – Rozen Nov 21 '13 at 02:46