AmitDiwan has Published 8358 Articles
AmitDiwan
136 Views
The following syntax will fetch all the values from the column −select * from yourTableName where yourColumnName=0;Let us first create a table −mysql> create table DemoTable1791 ( FirstName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert ... Read More
AmitDiwan
213 Views
Let us first create a table −mysql> create table DemoTable1795 ( Name varchar(20), DueDate date ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1795 values('John', '2018-07-21'); Query OK, 1 row affected ... Read More
AmitDiwan
806 Views
For this, you can use TRUNCATE TABLE command. Let us first create a table −mysql> create table DemoTable1796 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using ... Read More
AmitDiwan
337 Views
For this, you can use STR_TO_DATE(), since we have date records in the following format: 21/11/2019.Let us first create a table −mysql> create table DemoTable1808 ( AdmissionDate varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command ... Read More
AmitDiwan
533 Views
Following is the syntax to match date with date() function and updating a column −update yourTableName set yourColumnName=yourValue where date(yourColumnName)=curdate();Let us first create a table −mysql> create table DemoTable1816 ( Name varchar(20), JoiningDate datetime ); Query OK, 0 rows affected (0.00 sec)Insert ... Read More
AmitDiwan
227 Views
For this, you can use COUNT() along with GROUP BY MONTH(). To match with the current date, use CURRENT_DATE(). The current date is as follows −mysql> select curdate() ; +------------+ | curdate() | +------------+ | 2019-11-30 | +------------+ 1 row in set (0.00 sec)Let us first create a table −mysql> ... Read More
AmitDiwan
6K+ Views
To check for NULL or empty variable, use the IF condition. Let us create a stored procedure −mysql> delimiter // mysql> create procedure checkingForNullDemo(Name varchar(20)) begin if Name is NULL OR Name='' then select 'Adam Smith'; else select Name; ... Read More
AmitDiwan
140 Views
To use comparison operator for numeric string, use the substring() method. Let us first create a table −mysql> create table DemoTable1881 ( UserId int, UserEducationGap varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1881 ... Read More
AmitDiwan
357 Views
Let us first create a table −mysql> create table DemoTable658(FirstName varchar(100), value char(2)); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command −mysql> insert into DemoTable658(FirstName) values('John') ; Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable658(value, FirstName) values(default(value), 'Sam'); Query OK, ... Read More
AmitDiwan
192 Views
For this, use ORDER BY ISNULL(). Let us first create a table −mysql> create table DemoTable669 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentScore int ); Query OK, 0 rows affected (0.55 sec)Insert some records in the table using insert command −mysql> insert into DemoTable669(StudentScore) values(45) ; ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP