ProblemYou want to specify a statement to be executed directly on the mysql command line. Solutionmysql can read a statement from its argument list. DiscussionTo execute a statement directly from the command line, specify it using the -e (or --execute) option. For example, to find out how many rows are in the limbs table, run this command: % mysql -e "SELECT COUNT(*) FROM limbs" cookbook +----------+ | COUNT(*) | +----------+ | 12 | +----------+ To execute multiple statements this way, separate them with semicolons: % mysql -e "SELECT COUNT(*) FROM limbs;SELECT NOW()" cookbook +----------+ | COUNT(*) | +----------+ | 12 | +----------+ +---------------------+ | NOW() | +---------------------+ | 2006-07-04 10:42:22 | +---------------------+ By default, results generated by statements that are specified with -e are displayed in tabular format if output goes to the terminal, and in tab-delimited format otherwise. To learn what these different formats are, see Section 1.17. To choose a particular format, see Section 1.18. |