
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
114 Views
No, the query won’t work. Let’s create the same scenario and check the error −mysql> create table DemoTable1821 ( Id int, FirstName varchar, LastName varchar ); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual ... Read More

AmitDiwan
227 Views
For this, you can use DATE_FORMAT(). Let us first create a table −mysql> create table DemoTable1820 ( AdmissionDate varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1820 values('20/10/2019'); Query OK, 1 row ... Read More

AmitDiwan
371 Views
To count the same value of each row, use COUNT(*) along with GROUP BY clause. Let us first create a table −mysql> create table DemoTable1818 ( Id int, Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the ... Read More

AmitDiwan
1K+ Views
To pass multiple ids to single parameter, use FIND_IN_SET(). Let us first create a table −mysql> create table DemoTable1817 ( EmployeeName varchar(20), CountryName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert ... Read More

AmitDiwan
380 Views
To randomly select, use ORDER BY RAND(). To select only 2 values, use LIMIT 2 in MySQL. Let us first create a table −mysql> create table DemoTable1815 ( Question text ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using ... Read More

AmitDiwan
498 Views
To implement DOUBLE in MySQL, the syntax is as follows −create table yourTableName ( yourColumnName double(5, 2) unsigned );Let us first create a table −mysql> create table DemoTable1814 ( Amount double(5, 2) unsigned ); Query OK, 0 rows affected (0.00 ... Read More

AmitDiwan
1K+ Views
For this, you can use GRANT SELECT statement as in the below syntax −GRANT SELECT ON *.* TO 'yourUserName'@'yourHostName';First list all the user names along with host −mysql> select user, host from mysql.user;This will produce the following output −+------------------+-----------+ | user | ... Read More

AmitDiwan
2K+ Views
For this, use UNION ALL. Let us first create a table −mysql> create table DemoTable1813 ( Name1 varchar(20), Name2 varchar(20) ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1813 values('John', 'Chris'); ... Read More

AmitDiwan
479 Views
To extract column name and type, use INFORMATION_SCHEMA.COLUMNS −select concat(column_name, '=', data_type) as anyAliasName from information_schema.columns where table_schema= yourDatabaseName and table_name= yourTableName;Let us first create a table −mysql> create table DemoTable1812 ( Id int, FirstName varchar(20), Age int, isMarried boolean, ... Read More

AmitDiwan
401 Views
Let us first create a table −mysql> create table DemoTable1811 ( FirstName varchar(20), LastName varchar(20) ); Query OK, 0 rows affected (0.00 sec)Here is the query to add indexmysql> alter table DemoTable1811 ADD UNIQUE unique_index_first_last_name(FirstName, LastName); Query OK, 0 rows affected (0.00 ... Read More