Solved

mysql how can I execute a query, direct it to an output file, and not have it include in the output file the query I ran to get the data?

Posted on 2010-09-22
5
404 Views
Last Modified: 2012-05-10
I am developing a mysql report and I need to know direct it to an output filewithout the output file including the query I ran to generate the data?  Currently, even if I run it in silent mode and redirect it with the tee command, it sill places in the output file the query I ran.  I don't want that to show up in the report.  Does anyone have any ideas?
0
Comment
Question by:navajo26354
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 15

Accepted Solution

by:
David L. Hansen earned 500 total points
ID: 33736309
0
 
LVL 21

Expert Comment

by:theGhost_k8
ID: 33736319
mysql -uUSER -pPASS databasename -e  "YOUR QUERY" > outputfile.txt
0
 
LVL 4

Expert Comment

by:max-hb
ID: 33736333
Hi!
Assuming you are using Linux/Unix try this:

mysql -insert-your-options < query.sql > outfile.txt

Replace "-insert-your-options" with any information needed to connect to your database, eg. "-u root -p secrecy -h localhost" etc.

CU
 maxhb
0
 
LVL 1

Expert Comment

by:eekygeeky
ID: 33736341
To the best of my knowledge, there's no way to do that . You can output the data to a .csv file and anything you use to read the .csv file will ignore the SELECT statement because it won't output as comma seperated. in a .txt file, you will always see the query.

-tee just forks the output so it goes two places at once, like on the screen and to a log file simultaneously.

Most websitesand repotr generating tools  handle this with PHP or something , that can be used to automatically look at the query results and generate a pretty looking webpage or Word document or something. Excel can import .CSVs directly if that's any help.
0
 
LVL 6

Expert Comment

by:bimal_linux
ID: 33741226
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP & MySQL - Rounding Results from a Select Query 3 46
MS Access - need to reduce row size 25 76
Unwanted output from my query 5 52
phpmyadmin memory error 55 91
Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Creating and Managing Databases with phpMyAdmin in cPanel.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question