- 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
1K+ Views
Let us first create a table −mysql> create table DemoTable ( `Values` varchar(50) ); Query OK, 0 rows affected (1.15 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('23, 45, 78, 56'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('384, 476, 7456'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('68, 8, 88, 89'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('78, 80, 84'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This ... Read More
173 Views
Let us first create a table −mysql> create table DemoTable ( EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeName varchar(40), isMarried boolean ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(EmployeeName, isMarried) values('Chris', true); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(EmployeeName, isMarried) values('Robert', false); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(EmployeeName, isMarried) values('Mike', false); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(EmployeeName, isMarried) values('Bob', true); Query OK, 1 row affected (0.07 sec) mysql> insert into ... Read More
4K+ Views
Let us first create a table −mysql> create table DemoTable ( ClientId int, ClientName varchar(50) ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command. Here, we are inserting multiple values using only a single INSERT −mysql> insert into DemoTable values(101,'Adam'),(102,'Chris'),(103,'Robert'),(104,'Sam'),(105,'Mike'); Query OK, 5 rows affected (0.16 sec) Records: 5 Duplicates: 0 Warnings: 0Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----------+------------+ | ClientId | ClientName | +----------+------------+ | 101 | Adam | | 102 | Chris | | 103 | Robert | | 104 | Sam | | 105 | Mike | +----------+------------+ 5 rows in set (0.00 sec)
73 Views
You can use FIND_IN_SET to structure some data in a database for easier retrieval. Let us first create a table −mysql> create table DemoTable ( CountryName SET('US', 'UK', 'AUS') ); Query OK, 0 rows affected (0.49 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('US'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('UK'); Query OK, 1 row affected (0.09 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+-------------+ | CountryName | +-------------+ | US ... Read More
1K+ Views
Use MySQL INTERVAL for this. Let us first create a table −mysql> create table DemoTable ( DueDate date ); Query OK, 0 rows affected (1.13 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2019-07-10'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('2019-09-02'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('2019-06-01'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('2019-05-10'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('2019-08-21'); Query OK, 1 row affected (0.14 sec)Display all records from the table ... Read More
71 Views
Use nested insert with select in MySQL for this as shown in the below syntax −insert into yourTableName2(yourColumnName1, yourColumnName2, .....N) select yourColumnName1, yourColumnName2, ....N from yourTableName1 where yourCondition;Let us first see an example and create a table −mysql> create table DemoTable1 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(40) ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(Name) values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1(Name) values('David'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1(Name) values('Bob'); Query OK, ... Read More
What happens when you insert nothing after declaring a column “timestamp default CURRENT_TIMESTAMP”?
106 Views
In this case, the current timestamp gets inserted into the table column. Let us first create a table −mysql> create table DemoTable ( ArrivalDate timestamp default CURRENT_TIMESTAMP ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(now()); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.13 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------------+ | ArrivalDate | +---------------------+ | 2019-09-01 14:08:47 | | 2019-09-01 14:08:50 | +---------------------+ 2 rows in set (0.00 sec)
381 Views
You can use the conv() function along with the cast() to cast from hexadecimal to a decimal value.Note − MD5 is in hexadecimalLet us first create a table −mysql> create table DemoTable ( Password text ); Query OK, 0 rows affected (0.60 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values("a5391e96f8d48a62e8c85381df108e98"); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values("ea7a32d2dc5bb793af262dcb6ea1a54d"); Query OK, 1 row affected (0.18 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+----------------------------------+ | Password ... Read More
289 Views
You can try to get a column’s maximum value using two ways. The first way is as follows −select max(yourColumnName) from yourTableName;The second way is as follows −select yourColumnName from yourTableName order by yourColumnName DESC LIMIT 1;NOTE − The first query takes less time than the second query because the second query first sort n number of values then gives the highest value using LIMIT 1. Therefore, use the first query.Let us first create a table −mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command ... Read More
117 Views
Let us first create a table −mysql> create table DemoTable ( AdmissionDate timestamp ); Query OK, 0 rows affected (0.90 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2007-01-10'); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable values('2015-07-12'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('2017-11-01'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('2019-08-29'); Query OK, 1 row affected (0.08 sec)Display all records from the table using select statement −mysql> select *from DemoTable;This will produce the following output −+---------------------+ | AdmissionDate ... Read More