- 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)
614 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> ); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, NULL); Query OK, 1 row affected (0.32 sec) mysql> insert into DemoTable values(NULL, 'David'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(NULL, NULL); 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−+------+-------+ | Id | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
86 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris Brown'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Adam Smith'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('John Smith'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Carol Smith'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
361 Views
Let us first create a table −mysql> create table DemoTable -> ( -> BreakfastTime time -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('7:30:45'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('8:00:30'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values('7:55:00'); Query OK, 1 row affected (0.10 sec)Display all records from the table using select statement −mysql> select * from DemoTable;This will produce the following output −+---------------+ | BreakfastTime | +---------------+ | 07:30:45 | | ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
281 Views
To get the database name, use the below given syntax −select database();Let us implement the above syntax in the stored procedure −mysql> delimiter // mysql> create procedure get_procedure_database_name() -> begin -> select concat('The database name=',database()); -> end -> // Query OK, 0 rows affected (0.34 sec) mysql> delimiter ;Now you can call a stored procedure using CALL command −mysql> call get_procedure_database_name();This will produce the following output −+-----------------------------------------+ | concat('The database name=',database()) | +-----------------------------------------+ | The database name=web | +-----------------------------------------+ 1 row in set (0.05 sec) Query OK, 0 rows affected (0.08 sec)
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
83 Views
Let us first create a table −mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(45); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(85); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.10 sec)Display all records from the table ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
126 Views
To change the MySQL ending statement, you can use DELIMITER −DELIMITER anySymbolAbove, anySymbol is the symbol you can set. The default is DELIMITER ;Let us first create a table −mysql> DELIMITER // mysql> create table DemoTable -> ( -> Id int, -> Name varchar(20) -> )// Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'Chris')// Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values(101, 'David')// Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(102, 'Bob')// Query OK, 1 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
577 Views
To set conditions, use CASE WHEN statement in MySQL. Let us first create a table −mysql> create table DemoTable -> ( -> Value1 int, -> Value2 int, -> Value3 int, -> Value4 int -> ); Query OK, 0 rows affected (0.98 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(1, 0, 1, 1); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values(1, 0, 1, 0); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(1, 1, 1, 1); Query OK, 1 row affected (0.20 ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
236 Views
To set conditions while adding column values, use MySQL IF(). Let us first create a table −mysql> create table DemoTable -> ( -> Value1 int, -> Value2 int, -> Value3 int -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 20, -30); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(50, 60, 90); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values(100, 200, 400); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(30, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
777 Views
The group is a reserved keyword, you can’t use it as table name. Therefore, on using it as table name would lead to an error. To avoid such error, you need to use enclosed backticks symbol around the table name ‘group’.Let us now see an example and create a table −mysql> create table `group` -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(20) -> ); Query OK, 0 rows affected (1.26 sec)Insert some records in the table using insert command −mysql> insert into `group`(Name) values('Chris'); Query OK, 1 row affected (0.47 sec) ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
310 Views
Let’s say, here I am using the WEB database. We need to find the number of tables in the database WEB. For this, use the INFORMATION_SCHEMA.TABLES in MySQL.Following is the query to display the number of tables −mysql> select count(table_name) as TotalNumberOfTablesInWebDatabase -> from information_schema.tables -> where table_schema='web';This will produce the following output −+----------------------------------+ | TotalNumberOfTablesInWebDatabase | +----------------------------------+ | 1562 | +----------------------------------+ 1 row in set (0.27 sec)To just check whether the count of records displayed above are the same or not, use the ... Read More