- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4378 Articles for MySQL
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
3K+ Views
To save time in milliseconds, we can use now(3) function because “milli 3” can be used for te same purpose. Firstly, I will create a table with the help of CREATE command −mysql> CREATE table MilliSecondDemo -> ( -> MyTimeInMillSec datetime(3) -> ); Query OK, 0 rows affected (0.70 sec)Inserting record into the table −mysql> INSERT into MilliSecondDemo values(now(3)); Query OK, 1 row affected (0.98 sec)Let us now view the table records −mysql> SELECT * from MilliSecondDemo; The following is the output+-------------------------+ | MyTimeInMillSec | +-------------------------+ | 2018-10-08 15:19:50.202 | +-------------------------+ 1 row in set (0.00 sec)
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
18K+ Views
To select a column name with spaces, use the back tick symbol with column name. The symbol is ( ` `). Back tick is displayed in the keyboard below the tilde operator ( ~).Firstly, create a table −mysql> CREATE table SpaceColumn -> ( -> `Student Name` varchar(100) -> ); Query OK, 0 rows affected (0.48 sec)Inserting recordsmysql> INSERT into SpaceColumn values('John'); Query OK, 1 row affected (0.18 sec) mysql> INSERT into SpaceColumn values('Bob'); Query OK, 1 row affected (0.17 sec)The syntax to get column name with space is as follows −SELECT `column_name` from yourTableName; Now I will apply the ... Read More
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
696 Views
Firstly, we will create a table with the help of CREATE command.Creating a table −mysql> CREATE table InCaseSensDemo -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.50 sec)Inserting records into the table with the help of INSERT command −mysql> INSERT into InCaseSensDemo values('JOhN'); Query OK, 1 row affected (0.11 sec) mysql> INSERT into InCaseSensDemo values('bob'); Query OK, 1 row affected (0.21 sec) mysql> INSERT into InCaseSensDemo values('BoB'); Query OK, 1 row affected (0.13 sec) mysql> INSERT into InCaseSensDemo values('Bob'); Query OK, 1 row affected (0.18 sec)Displaying all the records with the help of ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
170 Views
We can do this with the help of lower() with column name. Firstly, we will create a table with the help of CREATE command.Creating a table −mysql> CREATE table InCaseSensDemo -> ( -> Name varchar(100) -> ); Query OK, 0 rows affected (0.50 sec)Inserting records into the table with the help of INSERT command −mysql> INSERT into InCaseSensDemo values('JOhN'); Query OK, 1 row affected (0.11 sec) mysql> INSERT into InCaseSensDemo values('bob'); Query OK, 1 row affected (0.21 sec) mysql> INSERT into InCaseSensDemo values('BoB'); Query OK, 1 row affected (0.13 sec) mysql> INSERT into InCaseSensDemo values('Bob'); Query OK, ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
4K+ Views
SELECT DISTINCT can be used to give distinct values. Use it to remove duplicate records and it can be used with aggregate function as well. For example: MAX, AVG etc. This can be applied on a single column.Now, I am creating a table to use SELECT DISTINCT for a column. Creating a table with the help of CREATE command −mysql> CREATE TABLE DistinctDemo -> ( -> id int, -> name varchar(100) -> ); Query OK, 0 rows affected (0.64 sec)Inserting records −mysql> INSERT into DistinctDemo values(1, 'John'); Query OK, 1 row affected (0.17 sec) mysql> INSERT into DistinctDemo values(2, ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
346 Views
To add 1 day, use date_add() function. Adding a day to datetime in MySQL gives the next day. The following is the syntax −SELECT DATE_ADD('Any date’', INTERVAL 1 DAY) AS AliasName;Now, I am applying the above query to add a day with date in MySQL. The query is as follows −mysql> SELECT DATE_ADD('2018-10-08', INTERVAL 1 DAY) AS NextDay; After executing the above query, we will get the following output −+------------+ | NextDay | +------------+ | 2018-10-09 | +------------+ 1 row in set (0.00 sec)Therefore, in this sample output, I am adding a day with current date
![Arjun Thakur](https://www.tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
1K+ Views
To enable query log, use the command SET global. You cannot use set general_log in MySQL version 8.0.12 version. If you are using version 8.0.12, then you will get the below given error. Here, we are trying to set general_log to see what error will come −mysql> SET general_log = 1;The following is the output −ERROR 1229 (HY000): Variable 'general_log' is a GLOBAL variable and should be set with SET GLOBAL Now, we will use the global command with general_log. The query is as follows −mysql> SET global general_log = 1; Query OK, 0 rows affected (0.10 sec)To check it ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
1K+ Views
Unsigned allows us to enter positive value; you cannot give any negative number. Let us create a table to understand unsigned in MySQL. To create a table, we will use the CREATE command.Let us create a table −mysql> CREATE table UnsignedDemo -> ( -> id int unsigned -> ); Query OK, 0 rows affected (0.61 sec)After that I will insert only positive values. Let us insert some records −mysql> INSERT into UnsignedDemo values(124); Query OK, 1 row affected (0.09 sec) mysql> INSERT into UnsignedDemo values(78967); Query OK, 1 row affected (0.14 sec)I am displaying all the records with the ... Read More
![Chandu yadav](https://www.tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
6K+ Views
To know the current auto_increment value, we can use the last_insert_id() function. Firstly, we will create a table with the help of INSERT command.Creating a table −mysql> CREATE table AutoIncrement -> ( -> IdAuto int auto_increment, -> primary key(IdAuto) -> ); Query OK, 0 rows affected (0.59 sec)After creating a table, we will insert the records with the help of INSERT command. Inserting records −mysql> INSERT into AutoIncrement values(); Query OK, 1 row affected (0.48 sec) mysql> INSERT into AutoIncrement values(); Query OK, 1 row affected (0.17 sec) mysql> INSERT into AutoIncrement values(); Query OK, 1 row affected ... Read More
![Ankith Reddy](https://www.tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
637 Views
To know the current time, we can use the now() function with SELECT statement. The query is as follows −mysql> SELECT now();After executing the above query, we will get the current time. The following is the output −+---------------------+ | now() | +---------------------+ | 2018-10-06 12:57:25 | +---------------------+ 1 row in set (0.02 sec)To set the time zone, we can use the command SET. The syntax is as follows −mysql> SET time_zone = "Some value"; Now I am applying the above query to set the time zone. ... Read More