

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Entering MySQL Queries
Before entering queries on the console, it is important to ensure that the user is connected to the server. The below query would give the version number of the server being used, and the current date.
mysql> SELECT VERSION(), CURRENT_DATE;
Note: The function ‘VERSION()’ and ‘CURRENT_DATE’ are case−insensitive. This means ‘version()’, ‘Version()’, ‘vERsion()’, all mean the same. Same goes with ‘CURRENT_DATE’
An SQL query is followed by a semi-colon.
When a query is issued to mysql, it sends the query to the server for execution. The results are computed and displayed. Another ‘mysql>’ also gets printed, indicating that the server is ready for one more query.
The output after executing the mysql query is in tabular form, i.e rows and columns. The first row contains the name of the columns. The remaining rows are the query results.
Once the query is executed, ‘mysql’ also gives the number of rows that were returned, the amount of time taken to execute the query. This gives the user a rough idea about the performance of the server.
MySQL server can also be used to execute multiple statement in a single line. It has been shown below −
mysql> SELECT VERSION(); SELECT NOW();
The ‘mysql’ server determines the end of the query statement by looking for the terminating semicolon, not the end of an input line. It can be seen in the following query −
mysql> SELECT −> USER() −> , −> VERSION();
In the above query, it is important to see that the prompt changed from ‘mysql>’ to ‘−>’ when it went to the next line, since this is a multi−line query. The terminating semi−colon was not encountered, hence it gave out a ‘−>’, else the query would have been sent to the server to get executed.
- Related Questions & Answers
- Entering JSON data into MySQL?
- Add results from several COUNT queries in MySQL?
- How to execute multiple select queries in MySQL ?
- How the MySQL command that you are in the process of entering can be canceled?
- How to set ImageView in edittext while entering text?
- MySQL queries to update date records with NULL values
- Best way to combine multiple advanced MySQL select queries?
- Making slow queries fast using composite indexes in MySQL
- Can I write my own MySQL functions to use in MySQL queries?
- How to list down all the running queries in MySQL?
- In SAP system, auto filling of NAME_1 while entering client number
- Queries Regarding nRF24L01 transceiver
- Media queries with CSS3
- Performing regex Queries with PyMongo?
- Palindrome Substring Queries in C++