AmitDiwan has Published 10744 Articles

How to check if any value is Null in a MySQL table single row?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:47:37

603 Views

For this, you can use ISNULL in MySQL.Let us create a table −Examplemysql> create table demo86    -> (    -> value1 varchar(20)    -> ,    -> value2 varchar(20)    -> ); Query OK, 0 rows affected (2.77Insert some records into the table with the help of insert command ... Read More

MySQL - SUM rows with same ID?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:44:45

8K+ Views

To sum rows with same ID, use the GROUP BY HAVING clause.Let us create a table −Examplemysql> create table demo84    -> (    -> id int,    -> price int    -> )    -> ; Query OK, 0 rows affected (0.60Insert some records into the table with the ... Read More

MySQL query for INSERT INTO using values from another table?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:42:20

918 Views

For this, use INSERT INTO SELECT statement.Let us create a table −Examplemysql> create table demo82    -> (    -> id int,    -> name varchar(20)    -> ); Query OK, 0 rows affected (2.06Insert some records into the table with the help of insert command −Examplemysql> insert into demo82 ... Read More

MySQL Select where values IN List string?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:39:59

4K+ Views

For this, use FIND_IN_SET().Let us create a table −Examplemysql> create table demo81    -> (    -> id int not null auto_increment primary key,    -> username varchar(200)    -> ); Query OK, 0 rows affected (1.44Insert some records into the table with the help of insert command −Examplemysql> insert ... Read More

Show date like 30-04-2020 instead of 2020-04-30 from MySQL database?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:38:01

87 Views

For this, use DATE_FORMAT() in MySQL. The syntax is as follows −Exampleselect date_format(yourColumnName, '%d-%m-%Y') as anyAliasName from yourTableName;Let us create a table −Examplemysql> create table demo80    -> (    -> due_date date    -> ); Query OK, 0 rows affected (0.74Insert some records into the table with the help ... Read More

Split a column in 2 columns using comma as separator - MySQL

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:35:52

4K+ Views

For this, you can use substring_index() in MySQL. Let us create a table −Examplemysql> create table demo79    -> (    -> fullname varchar(50)    -> ); Query OK, 0 rows affected (0.64Insert some records into the table with the help of insert command −Examplemysql> insert into demo79 values("John, Smith"); ... Read More

How to get username using ID from another table in MySQL database?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:33:37

3K+ Views

To get username using ID from two tables, you need to use JOIN and join the tables.Let us create a table −Examplemysql> create table demo77    -> (    -> userid int not null primary key,    -> username varchar(20)    -> ); Query OK, 0 rows affected (2.63Insert some ... Read More

Find all users with a unique last name in MySQL?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:30:40

560 Views

To find all users with unique last name, use GROUP BY HAVING COUNT().Let us create a table −Examplemysql> create table demo76    -> (    -> firstName varchar(20),    -> lastName varchar(20)    -> ); Query OK, 0 rows affected (9.29Insert some records into the table with the help of ... Read More

Fetching rows updated at timestamp older than 1 day in MySQL?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:28:02

876 Views

For this, yYou can use from_unixtime() along with now().Let us create a table with some data type −Examplemysql> create table demo75    -> (    -> due_date int(11)    -> ); Query OK, 0 rows affected, 1 warning (2.87Insert some records into the table with the help of insert command ... Read More

MySQL LIKE query with dynamic array?

AmitDiwan

AmitDiwan

Updated on 11-Dec-2020 05:23:57

2K+ Views

To implement LIKE query with dynamic array, the syntax is as follows −Exampleselect *from yourTableName    where yourColumnName2 like "%yourValue%"    order by yourColumnName1 asc    limit yourLimitValue;Let us create a table −Examplemysql> create table demo74    -> (    -> user_id int not null auto_increment primary key,    -> ... Read More

Advertisements