- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 11365 Articles
AmitDiwan
120 Views
The easiest way to achieve this is by using the MySQL SUBSTRING_INDEX() function. Let us first create a table −mysql> create table DemoTable ( ZipCode varchar(50) ); Query OK, 0 rows affected (2.02 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('52533-909'); Query OK, ... Read More
AmitDiwan
2K+ Views
Use UNION to select from two tables. Let us first create a table −mysql> create table DemoTable1 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 rows affected (0.90 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(FirstName) values('Chris') ... Read More
AmitDiwan
407 Views
For the lowest values in a MySQL column, use the MIN() method and for highest, use the MAX() method. Let us first create a table −mysql> create table DemoTable ( CustomerName varchar(20), ProductAmount int ) ; Query OK, 0 rows affected (1.03 sec)Insert some records in the table ... Read More
AmitDiwan
189 Views
Use MySQL IN() to avoid too many OR statements. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(40) ); Query OK, 0 rows affected (0.89 sec)Insert some records in the table using insert command −mysql> insert into ... Read More
AmitDiwan
2K+ Views
To select different values on the basis of condition, use CASE statement. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(40), Score int ) ; Query OK, 0 rows affected (0.54 sec)Insert some records in the table ... Read More
AmitDiwan
590 Views
To randomly select rows, use ORDER BY RAND() with LIMIT. Use DISTINCT for distinct rows. Let us first see an example and create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(40) ); Query OK, 0 rows affected (0.54 sec)Insert some ... Read More
AmitDiwan
101 Views
Such errors arise when you avoid using the DELIMITER concept. Let us see an example and run a query for stored procedure −mysql> DELIMITER // mysql> CREATE PROCEDURE correct_procedure() BEGIN SELECT 'Hello MySQL !!!'; END // Query OK, 0 rows affected (0.12 sec) mysql> DELIMITER ;Following is ... Read More
AmitDiwan
170 Views
To set new delay time, use INTERVAL and update the column wth SETa clause and UPDATE command. Let us first create a table −mysql> create table DemoTable ( DelayTime time ); Query OK, 0 rows affected (1.21 sec)Insert some records in the table using insert command −mysql> insert into ... Read More
AmitDiwan
175 Views
Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY , Title text ); Query OK, 0 rows affected (0.88 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Title) values('This is; a; MySQL;Tutorial'); Query OK, 1 ... Read More
AmitDiwan
968 Views
To find column names, use information_schema.columns. Following is the syntax −select distinct table_name from information_schema.columns where column_name like '%yourSearchValue%' and table_schema=database();Let us implement the above syntax in order to find column names across various table. Here, we want only table names with a specific column name word “Client” −mysql> select ... Read More