AmitDiwan has Published 11365 Articles

MySQL multiple COUNT with multiple columns?

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 07:05:35

290 Views

You can use an aggregate function SUM() along with IF(). Let us first create a table −mysql> create table DemoTable (    FirstName varchar(100),    LastName varchar(100) ); Query OK, 0 rows affected (2.80 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Adam', 'Smith'); Query ... Read More

Use LIKE % to fetch multiple values in a single MySQL query

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 07:00:04

3K+ Views

To fetch multiple values wit LIKE, use the LIKE operator along with OR operator. Let us first create a table −mysql> create table DemoTable1027 (    Id int,    Name varchar(100) ); Query OK, 0 rows affected (1.64 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

MySQL select query to fetch data with null value?

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 06:57:06

395 Views

Let us first create a table −mysql> create table DemoTable (    CustomerName varchar(100),    CustomerCountryName varchar(100) ); Query OK, 0 rows affected (0.95 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('Chris', 'US'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable ... Read More

Show column value twice in MySQL Select?

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 06:54:42

212 Views

You can use concat(). Let us first create a table −mysql> create table DemoTable (    Value int ); Query OK, 0 rows affected (0.73 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable ... Read More

Get count of zeros for columns values declared with INT type in MySQL

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 06:52:26

181 Views

For this, you can use LENGTH() along with REPLACE(). Let us first create a table −mysql> create table DemoTable (    Value int ); Query OK, 0 rows affected (1.22 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10002000); Query OK, 1 row affected (0.09 ... Read More

Return value from a row if it is NOT NULL, else return the other row value in another column with MySQL

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 06:50:15

197 Views

For this, you can use IFNULL(). Let us first create a table −mysql> create table DemoTable (    FirstName varchar(100),    LastName varchar(100) ); Query OK, 0 rows affected (0.62 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John', 'Doe'); Query OK, 1 row affected ... Read More

MySQL query to compare and display only the rows with NULL values

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 06:48:14

112 Views

For this, you can use IFNULL(). Let us first create a table −mysql> create table DemoTable (    Value1 int,    Value2 int ); Query OK, 0 rows affected (0.75 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(10, NULL); Query OK, 1 row affected ... Read More

MySQL UNIQUE declaration to avoid inserting duplicate values?

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 06:46:13

186 Views

Following is the declaration for a UNIQUE clause in MySQL −create table yourTableName (    yourColumnName1 dataType,    yourColumnName2 dataType,    UNIQUE(yourColumnName1),    UNIQUE(yourColumnName1) );Let us first create a table −mysql> create table DemoTable (    Value int,    Value2 int,    UNIQUE(Value),    UNIQUE(Value2) ); Query OK, 0 rows ... Read More

Display distinct dates in MySQL from a column with date records

AmitDiwan

AmitDiwan

Updated on 30-Sep-2019 06:44:28

410 Views

Let us first create a table −mysql> create table DemoTable (    AdmissionDate datetime ); Query OK, 0 rows affected (8.99 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('2010-01-10 12:30:45'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('2010-01-10 12:30:45'); Query ... Read More

HTML DOM aside Object

AmitDiwan

AmitDiwan

Updated on 27-Sep-2019 13:07:45

112 Views

The HTML DOM Aside Object represent the element of an HTML document.Create aside object−SyntaxFollowing is the syntax −document.createElement(“ASIDE”);Let us see an example of aside object−Example Live Demo    body {       text-align: center;       background-color: #fff;       color: #0197F6;    }   ... Read More

Advertisements