
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
AmitDiwan has Published 10744 Articles

AmitDiwan
454 Views
To get whether a column is a primary key, use COLUMN_NAME and COLUMN_KEY='PRI'. With that, the entire syntax is as follows −select column_name, case when column_key= 'PRI' then 'yourMessage1' else ''yourMessage2' end as anyAliasName from information_schema.columns where table_schema =database() and `table_name` = yourTableName order by `table_name`, ordinal_position;To understand the above ... Read More

AmitDiwan
596 Views
For this, you can use GROUP BY HAVING clause along with IN(). Let us first create a table −mysql> create table DemoTable1885 ( FirstName varchar(20), Subject varchar(50) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into ... Read More

AmitDiwan
262 Views
Let us first create a table −mysql> create table DemoTable1884 ( Marks int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1884 values(55); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1884 values(97); Query ... Read More

AmitDiwan
231 Views
Yes, we can do that. The syntaxes are as follows −Syntax1: select * from yourTableName1, yourTableName2; Syntax2: select * from yourTableName1 cross join yourTableName2;Both the above syntaxes give the same result.Let us first create a table −mysql> create table DemoTable1882 ( Id int ); Query OK, 0 ... Read More

AmitDiwan
3K+ Views
For this, use INSERT INTO SELECT statement. Let us first create a table −mysql> create table DemoTable1879 ( Id int, Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1879 values(101, 'Chris Brown'); Query ... Read More

AmitDiwan
213 Views
Use IFNULL() to find and place a specific value for NULL values. Let us first create a table −mysql> create table DemoTable1878 ( FirstName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1878 values('Chris'); Query ... Read More

AmitDiwan
5K+ Views
Let us first create a table −mysql> create table DemoTable1877 ( DueDate datetime ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1877 values('2019-12-10'); Query OK, 1 row affected (0.00 sec) ... Read More

AmitDiwan
615 Views
Let us first create a table −mysql> create table DemoTable1875 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Class varchar(20), Amount int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1875(Class, Amount) ... Read More

AmitDiwan
1K+ Views
For this, use CASE statement with UPDATE command. Let us first create a table −mysql> create table DemoTable1874 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Amount varchar(100) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command ... Read More

AmitDiwan
411 Views
To update a single column, use UPDATE and SET as in the below syntax −update yourTableName set yourColumnName=yourValue;Let us first create a table −mysql> create table DemoTable1873 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 rows ... Read More