News:
- In an internet driven environment, it is imperative for a company to keep its product or business to the forefront of potential customers' minds. The ...
- A successful enterprise is all about constantly reinventing ways to work more efficiently. In today’s techno age, this translates to testing new too...
- The IT industry plays a pivotal role in providing application development solutions and custom software development to a wide range of industries, i...
- Royal Victorian Eye and Ear Hospital, 2010 Atcomm has been contracted to implement a complex IOP glaucoma management tool which will be distribut...
- We are pleased to announce another implementation of a CMS system for a large Melbourne based fitness center - Star Plate Studio. Atcomm has depl...
-
font size
decrease font size
increase font size
1.18.1 Problem
You want to specify a query directly on the command line for mysql to execute.
1.18.2 Solution
mysql can read a query from its argument list. Use the -e (or --execute) option to specify a query on the command line.
1.18.3 Discussion
For example, to find out how many records are in the limbs table, run this command:
% mysql -e "SELECT COUNT(*) FROM limbs" cookbook +----------+ | COUNT(*) | +----------+ | 12 | +----------+
To run multiple queries with the -e option, separate them with semicolons:
% mysql -e "SELECT COUNT(*) FROM limbs;SELECT NOW( )" cookbook +----------+ | COUNT(*) | +----------+ | 12 | +----------+ +---------------------+ | NOW( ) | +---------------------+ | 2001-07-04 10:42:22 | +---------------------+
1.18.4 See Also
By default, results generated by queries that are specified with -e are displayed in tabular format if output goes to the terminal, and in tab-delimited format otherwise. To produce a different output style
Read 155 times
Published in
MySQL