- 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
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
985 Views
For this, use the RIGHT() method to fetch records with a specific last digit. Let us first create a table −mysql> create table DemoTable823(Value varchar(100)); Query OK, 0 rows affected (0.54 sec)Insert some records in the table using insert command −mysql> insert into DemoTable823 values('9847826'); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable823 values('84747464'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable823 values('9899889883'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable823 values('123456'); Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement −mysql> select *from DemoTable823;This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
321 Views
Let us first create a table −mysql> create table DemoTable848( ProductId int, ProductPrice int ); Query OK, 0 rows affected (1.20 sec)Insert some records in the table using insert command −mysql> insert into DemoTable848 values(100, 30); Query OK, 1 row affected (0.57 sec) mysql> insert into DemoTable848 values(101, 50); Query OK, 1 row affected (1.06 sec) mysql> insert into DemoTable848 values(100, 40); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable848 values(101, 25); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable848 values(100, 20); Query OK, 1 row affected (0.31 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
378 Views
For this, use ORDER BY INSTR(). Let us first create a table −mysql> create table DemoTable822(Word text); Query OK, 0 rows affected (1.11 sec)Insert some records in the table using insert command −mysql> insert into DemoTable822 values('Forever'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable822 values('ever'); Query OK, 1 row affected (1.31 sec) mysql> insert into DemoTable822 values('every'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable822 values('everyday'); Query OK, 1 row affected (0.58 sec)Display all records from the table using select statement −mysql> select *from DemoTable822;This will produce the following output −+----------+ | Word ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
214 Views
For this, use NOT IN. Let us first create a table −mysql> create table DemoTable(Value int); Query OK, 0 rows affected (0.71 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1234); Query OK, 1 row affected (0.54 sec) mysql> insert into DemoTable values(2345); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(7896); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(4321); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-------+ | Value | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
148 Views
Let us first create a table −mysql> create table DemoTable821(AdmissionDate datetime); Query OK, 0 rows affected (1.24 sec)Insert some records in the table using insert command −mysql> insert into DemoTable821 values('2019-01-21'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable821 values('2018-11-02'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable821 values('2016-12-31'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable821 values('2015-03-19'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable821;This will produce the following output −+---------------------+ | AdmissionDate ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
202 Views
If you compare the operator with NULL value then you will get NULL value always and no result.Let us see some examples for comparison −mysql> select 10 NULL; +------------+ | 10 NULL | +------------+ | NULL | +------------+ 1 row in set (0.00 sec) mysql> select NULL NULL; +--------------+ | NULL NULL | +--------------+ | NULL | +--------------+ 1 row in set (0.00 sec) mysql> select 'Chris' NULL; +-----------------+ | 'Chris' NULL | +-----------------+ | NULL | +-----------------+ 1 row in ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
255 Views
To fetch only the last five records below is the syntax −select *from yourTableName order by yourColumnName DESC LIMIT 5;Let us first create a table −mysql> create table DemoTable820( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(100) ); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command −mysql> insert into DemoTable820(CustomerName) values('Chris'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable820(CustomerName) values('Robert'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable820(CustomerName) values('David'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable820(CustomerName) values('Bob'); Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
131 Views
To display grants, the syntax is as follows −show grants for yourUserName;Let us implement the above syntax in order to check user rights before attempting to create database.Case 1 −This is for current user which is root. Following is the syntax −mysql> show grants for current_user;This will produce the following output −+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Grants for root@% ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Let us first create a table −mysql> create table DemoTable819( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100) ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable819(StudentName) values('Chris'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable819(StudentName) values('Robert'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable819(StudentName) values('Adam'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable819(StudentName) values('Mike'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable819(StudentName) values('Sam'); Query OK, 1 row affected (0.16 sec)Display all records from ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Let us first create a table −mysql> create table DemoTable845(AdmissionDate date); Query OK, 0 rows affected (1.10 sec)Insert some records in the table using insert command −mysql> insert into DemoTable845 values('2018-01-21'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable845 values('2016-12-12'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable845 values('2019-08-05'); Query OK, 1 row affected (0.44 sec) mysql> insert into DemoTable845 values('2019-10-15'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select *from DemoTable845;This will produce the following output −+---------------+ | AdmissionDate | +---------------+ | 2018-01-21 | ... Read More