Home > Database > Mysql Tutorial > body text

Enter MySQL query

WBOY
Release: 2023-08-24 09:29:06
forward
1301 people have browsed it

Enter MySQL query

It is important to ensure that the user is connected to the server before entering a query into the console. The query below will provide the server version number in use and the current date.

mysql> SELECT VERSION(), CURRENT_DATE;
Copy after login

Note: The functions 'VERSION()' and 'CURRENT_DATE' are case-insensitive. This means that 'version()', 'Version()', 'vERsion()' all mean the same thing. The same goes for 'CURRENT_DATE'.

  • A SQL query must be followed by a semicolon.

  • When a query is issued to mysql, it sends the query to the server for execution. Calculate the result and display it. A 'mysql>' will also be printed, indicating that the server is ready to receive another query.

  • The output after executing the mysql query is presented in table form, that is, rows and columns. The first row contains the names of the columns. The remaining rows are the query results.

  • Once the query has been executed, 'mysql' will also give you the number of rows returned and the time it took to execute the query. This gives the user a general idea of ​​the server's performance.

MySQL server can also be used to execute multiple statements in a row. This usage has been demonstrated below -

mysql> SELECT VERSION(); SELECT NOW();
Copy after login

The MySQL server determines the end of a query statement by looking for the terminating semicolon rather than the end of the input line. This can be seen in the following query:

mysql> SELECT
   −> USER()
   −> ,
   −> VERSION();
Copy after login

In the above query, it is important to note that when it wraps, the prompt changes from 'mysql>' to '−>' because this is a Multi-line query. Since no terminating semicolon was encountered, it outputs '−>', otherwise the query would have been sent to the server for execution.

The above is the detailed content of Enter MySQL query. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template