- 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
86 Views
Let us first create a table −mysql> create table DemoTable606 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100)); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable606(FirstName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable606(FirstName) values('Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable606(FirstName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable606(FirstName) values('David'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable606;This will produce the following output −+----+-----------+ ... Read More
101 Views
For this, you can use DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable605 (DueDate date); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable605 values('2019-01-21'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable605 values('2019-02-23'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable605 values(curdate()); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable605;This will produce the following output −+------------+ | DueDate | +------------+ | 2019-01-21 | | 2019-02-23 | | 2019-03-04 ... Read More
138 Views
Use FIND_IN_SET() for command separated argument. Let us first create a table −mysql> create table DemoTable604 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Title varchar(100)); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable604(Title) values('MySQL'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable604(Title) values('C++'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable604(Title) values('MongoDB'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable604(Title) values('Java'); Query OK, 1 row affected (0.14 sec)Display all records from the table using select statement −mysql> select *from DemoTable604;This ... Read More
3K+ Views
For this, you can use SHOW COLUMNS or INFORMATION_SCHEMA.COLUMN.Let us first create a table −mysql> create table DemoTable603 ( ClientId int NOT NULL AUTO_INCREMENT, ClientName varchar(100), ClientAge int, ClientAddress varchar(100), ClientCountryName varchar(100), ClientEducationDetails varchar(200), PRIMARY KEY(ClientId) ); Query OK, 0 rows affected (0.59 sec)CASE 1 − Using SHOW commandHere is the query to find the name of a column in MySQL −mysql> SHOW COLUMNS FROM DemoTable603;This will produce the following output −+------------------------+--------------+------+-----+---------+----------------+ | Field ... Read More
135 Views
Any identifiers like tablename, stored procedure, viewname or column etc. may be quoted or unquoted. When an identifier is a reserved keyword then you must quote it, else an error would occur.Let us first create a table. Here, we have taken field names as reserved keywords −mysql> create table `INT` (`select` int, `varchar` varchar(100)); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into `INT` values(1, 'MySQL'); Query OK, 1 row affected (0.14 sec) mysql> insert into `INT` values(2, 'MongoDB'); Query OK, 1 row affected (0.34 sec) mysql> insert into `INT` values(3, ... Read More
102 Views
For this, let us create a table, insert some values and use ORDER BY CASE. Let us first create a table −mysql> create table DemoTable602 (GameName text); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable602 values('Candy cash game'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable602 values('Pubg'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable602 values('cash Candy game'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable602 values('subway'); Query OK, 1 row affected (0.14 sec)Display all records from the table using ... Read More
80 Views
Let us first create a table −mysql> create table DemoTable664 (CityName varchar(100)); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command −mysql> insert into DemoTable664 values('Springfield'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable664 values('Austin'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable664 values('Franklin'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable664 values('OAKLAND'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable664 values('Anchorage'); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable664;This will ... Read More
691 Views
In ENUM data type, if you do not declare NOT NULL then it gives the default value NULL. However, if you declare NOT NULL then it gives the first value from the ENUM.CASE 1 −When the ENUM gives NULL value. Let us first create a table:mysql> create table DemoTable1(isMarried ENUM('YES', 'NO')); Query OK, 0 rows affected (0.76 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;This will produce the following output −+-----------+ | isMarried | +-----------+ ... Read More
2K+ Views
For this, use SUBSTRING_INDEX() and REPLACE(). Let us first create a table −mysql> create table DemoTable (Name varchar(100)); Query OK, 0 rows affected (0.53 sec)Insert some records in the table using insert command. Here, we have inserted last name and first names −mysql> insert into DemoTable values('Chris | Bob Brown'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Carol | Robert Taylor'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('Sam | David Miller'); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will ... Read More
321 Views
To combine multiple advanced MySQL select queries, use UNION. Let us first create a table −mysql> create table DemoTable1 (Value1 int, Value2 int); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(10, 29); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1 values(100, 190); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1 values(40, 101); Query OK, 1 row affected (0.12 sec)Display all records from the table using select statement −mysql> select *from DemoTable1;This will produce the following output −+--------+--------+ | Value1 | Value2 | ... Read More