
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 4381 Articles for MySQL

596 Views
Let us first create a table −mysql> create table DemoTable709 (Amount int); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable709 values(100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable709 values(560); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable709 values(7800); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable709 values(1020); Query OK, 1 row affected (0.15 sec)Display all records from the table using select statement −mysql> select *from DemoTable709;This will produce the following output -+--------+ | Amount | +--------+ | 100 ... Read More

2K+ Views
Let us first create a table −mysql> create table DemoTable708 ( CustomerName varchar(100), ShippingDate date ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable708 values('John', '2019-01-21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable708 values('Chris', '2019-03-24'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable708 values('Robert', '2019-04-26'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable708 values('David', '2019-07-22'); Query OK, 1 row affected (0.17 sec)Display all records from the table using select statement −mysql> select *from DemoTable708;This will produce the ... Read More

198 Views
Let us first create a table −mysql> create table DemoTable707 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100), StudentMarks int ); Query OK, 0 rows affected (0.59 sec)Insert some records in the table using insert command −mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values('John', 45); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values(NULL, 65); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values('Chris', 78); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable707(StudentFirstName, StudentMarks) values(NULL, 89); Query OK, 1 row affected (0.19 sec) mysql> insert into ... Read More

228 Views
To achieve this, following is the syntax wherein we have used DATE(NOW()) −select *from yourTableName where DATE(yourColumnName)=DATE(NOW());Let us first create a table −mysql> create table DemoTable706 ( UserId varchar(100), UserName varchar(100), UserSignupDate datetime ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable706 values('John1@gmail.com', 'John', '2019-01-31 12:45:22'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable706 values('Chris123@gmail.com', 'Chris', '2019-07-22 10:05:02'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable706 values('12Robert@gmail.com', 'Robert', '2019-06-22 11:25:22'); Query OK, 1 row affected (0.22 sec) mysql> insert into ... Read More

259 Views
Let’s say the current date is −2019-07-22Let us first create a table −mysql> create table DemoTable705 (ShippingDate datetime); Query OK, 0 rows affected (0.67 sec)Insert some records in the table using insert command −mysql> insert into DemoTable705 values('2019-01-21 23:59:00'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable705 values('2019-07-22 00:00:30'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable705 values('2019-07-21 12:01:30'); Query OK, 1 row affected (0.44 sec)Display all records from the table using select statement −mysql> select *from DemoTable705;This will produce the following output -+---------------------+ | ShippingDate | ... Read More

360 Views
Let us first create a table −mysql> create table DemoTable704 (SubjectName text); Query OK, 0 rows affected (0.58 sec)Insert some records in the table using insert command −mysql> insert into DemoTable704 values('Introduction to MySQL'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable704 values('Introduction to MongoDB'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable704 values('Introduction to MySQL'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable704 values('Introduction to Java'); Query OK, 1 row affected (0.39 sec) mysql> insert into DemoTable704 values('Introduction to MongoDB'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More

222 Views
For this, you can use CASE statement. Let us first create a table −mysql> create table DemoTable703 (Price int); Query OK, 0 rows affected (0.46 sec)Insert some records in the table using insert command −mysql> insert into DemoTable703 values(102); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable703 values(null); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable703 values(0); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable703 values(500); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable703 values(100); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable703 values(null); Query ... Read More

155 Views
You cannot give table name references because it is a reserved keyword. Wrap it using backticks, for example, `references`.Let us first create a table −mysql> create table `references`(Subject text); Query OK, 0 rows affected (0.44 sec)Insert some records in the table using insert command −mysql> insert into `references` values('Introduction To MySQL'); Query OK, 1 row affected (0.28 sec) mysql> insert into `references` values('Introduction To MongoDB'); Query OK, 1 row affected (0.15 sec) mysql> insert into `references` values('Introduction To Spring and Hibernate'); Query OK, 1 row affected (0.13 sec) mysql> insert into `references` values('Introduction To Java'); Query OK, 1 row affected ... Read More

102 Views
Let us first create a table −mysql> create table DemoTable702 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentScore int ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable702(StudentName, StudentScore) values('Chris', 56); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable702(StudentName, StudentScore) values('Robert', 21); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable702(StudentName, StudentScore) values('Mike', 89); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable702(StudentName, StudentScore) values('David', 99); Query OK, 1 row affected (0.20 sec)Display all records from ... Read More

150 Views
Here, we will see an example wherein we are inserting datetime and updating them while using INSERT query.Let us first create a table −mysql> create table DemoTable816 (DueDate datetime); Query OK, 0 rows affected (0.45 sec)Insert some records in the table using insert command. Here is the query to add (minutes / hours / days / months / years) to date when performing INSERT −mysql> insert into DemoTable816 values(date_add(now(), interval 3 minute)); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable816 values(date_add('2018-01-21 00:00:00', interval 3 Hour)); Query OK, 1 row affected (0.52 sec) mysql> insert into DemoTable816 values(date_add('2016-11-11 ... Read More