AmitDiwan has Published 11365 Articles

Compare date when the AdmissionDate is less than the current date in MySQL

AmitDiwan

AmitDiwan

Updated on 10-Oct-2019 11:41:28

241 Views

Let us first create a table −mysql> create table DemoTable (    AdmissionDate varchar(50) ); Query OK, 0 rows affected (0.63 sec)Note − Let’s say the current date is 14-Sep-2019.Insert some records in the table using insert command. Following is the query −mysql> insert into DemoTable values('15-Sep-2019'); Query OK, 1 ... Read More

Can we implement nested insert with select in MySQL?

AmitDiwan

AmitDiwan

Updated on 10-Oct-2019 11:39:16

445 Views

Yes, we can implement nested insert with select in MySQL 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 ... Read More

MySQL CASE WHEN with SELECT to display odd and even ids?

AmitDiwan

AmitDiwan

Updated on 10-Oct-2019 11:36:14

1K+ Views

Let us first create a table −mysql> create table DemoTable (    PageId int ); Query OK, 0 rows affected (0.85 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(233); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable values(34); Query OK, 1 ... Read More

Perform Multi-table delete in MySQL

AmitDiwan

AmitDiwan

Updated on 10-Oct-2019 11:33:23

108 Views

For this, you can use DELETE command. Let us first create a table −mysql> create table DemoTable1 (    Id int,    Name varchar(20) ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values(1, 'Chris'); Query OK, 1 row ... Read More

MySQL query to perform selection using AND OR

AmitDiwan

AmitDiwan

Updated on 09-Oct-2019 12:45:57

54 Views

Let us first create a table −mysql> create table DemoTable (    StudentId int,    StudentName varchar(20),    StudentSubject varchar(20) ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, 'Chris', 'MongoDB'); Query OK, 1 row affected (0.21 sec) ... Read More

MySQL Regex to match a pattern for ignoring a character in search like Chris.Brown?

AmitDiwan

AmitDiwan

Updated on 09-Oct-2019 12:42:07

98 Views

Let us first create a table −mysql> create table DemoTable (    Name varchar(40) ) ; Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John.Smith'); Query OK, 1 row affected (0.30 sec) mysql> insert into DemoTable values('Chris Brown'); Query ... Read More

MySQL query to group rows by the numeric characters in a string field?

AmitDiwan

AmitDiwan

Updated on 09-Oct-2019 12:39:43

104 Views

Fir this, you can concatenate 0 with string field with the help of + operator. The scenario here is like we need to fetch numeric “9844” from a string field “9844Bob”.Let us first create a table −mysql> create table DemoTable (    StudentId varchar(100) ); Query OK, 0 rows affected ... Read More

How to round MySQL column with float values and display the result in a new column?

AmitDiwan

AmitDiwan

Updated on 09-Oct-2019 12:36:12

454 Views

Let us first create a table −mysql> create table DemoTable (    Value float ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(12.4567); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(124.7884); Query OK, 1 ... Read More

Implement MySQL trigger in the first table to insert records in the second table?

AmitDiwan

AmitDiwan

Updated on 09-Oct-2019 12:34:23

186 Views

For this, the syntax is as follows −DELIMITER // create trigger yourTriggerName before insert on yourTableName1    for each row    begin          insert into yourTableName2 values (yourValue1, yourValue2, ...N); end ; // DELIMITER ;Let us first create a table −mysql> create table DemoTable1 (    StudentId ... Read More

MySQL query to select date from 00:00 to today’s date

AmitDiwan

AmitDiwan

Updated on 09-Oct-2019 12:30:58

280 Views

Let’s say the current date is 2019-09-14 8 :50 :10. Now, we want records from 00 :00 to 2019-09-14 8 :50 :10. Let us now see an example and create a table −mysql> create table DemoTable (    DueDate datetime ); Query OK, 0 rows affected (0.66 sec)Insert some records ... Read More

Advertisements