AmitDiwan has Published 11365 Articles

MySQL Stored Procedure calling with INT and VARCHAR values

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:36:19

889 Views

To call a stored procedure, you can use CALL command. Following is the syntax −CALL yourStoredProcedureName(parameter if any);Let us first create a sample procedure. Following is the query to create a stored procedure. Here, we have set two values, one is an INT and another VARCHAR −mysql> DELIMITER // mysql> ... Read More

How to execute multiple select queries in MySQL ?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:33:06

3K+ Views

To execute multiple select queries in MySQL, use the concept of DELIMITER. Let us first create a table −mysql> create table DemoTable1 (    Title text )ENGINE=MyISAM; Query OK, 0 rows affected (0.30 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1 values('The database MySQL is ... Read More

Why the following is showing an error in MySQL: INSERT INTO yourTableName VALUE(yourValue1,yourValue2,.......N);?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:28:01

110 Views

The error is in the syntax of VALUE().Use VALUES() instead of VALUE(). The correct syntax of the insert query is as follows −INSERT INTO yourTableName VALUES(yourValue1, yourValue2, .......N);Let us first create a table −mysql> create table DemoTable (    StudentId int,    StudentName varchar(40),    StudentAge int ); Query OK, ... Read More

How to create a new table from the first table using MySQL LIKE?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:25:21

56 Views

Let us first create a table −mysql> create table DemoTable1 (    EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    EmployeeName varchar(50) ); Query OK, 0 rows affected (0.48 sec)Insert some records in the table using insert command −mysql> insert into DemoTable1(EmployeeName) values('Tom'); Query OK, 1 row affected (0.19 sec) ... Read More

How to check the column values have string or digits in MySQL?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:22:19

824 Views

If you want only the string values, then use the below syntax −select *from yourTableName where yourColumnName NOT regexp '^[0-9]+$';If you want only the digit, then use the below syntax −select *from yourTableName where yourColumnName regexp '^[0-9]+$';Let us first create a table −mysql> create table DemoTable(    Id varchar(100) ); ... Read More

Insert multiple values in a temporary table with a single MySQL query?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:19:24

674 Views

Let us first create a table −mysql> create temporary table DemoTable (    SerialNumber int ); Query OK, 0 rows affected (0.00 sec)Insert some records in the table using insert command. Here, we are inserting multiple values in a temporary table −mysql> insert into DemoTable values(1), (2), (3), (4), (5), ... Read More

Check if the column values are the same among multiple records and set these records in a single row separated by a special character in MySQL

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:17:25

48 Views

For this, you can use GROUP_CONCAT() along with DISTINCT. Let us first create a table −mysql> create table DemoTable (    Id int,    Subject varchar(40) ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100, 'MySQL'); Query OK, ... Read More

MySQL query to display only the records that contains single word?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:15:37

237 Views

For this, you can filter records on the basis of LIKE. Let us first create a table −mysql> create table DemoTable (    Name varchar(50) ); Query OK, 0 rows affected (0.50 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('John Smith'); Query OK, 1 ... Read More

MySQL query to sort increasing the difference between n and the value in the table?

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:14:12

52 Views

For sort by distance, use ORDER BY ABS(). Let us first create a table −mysql> create table DemoTable (    Number int ); Query OK, 0 rows affected (1.16 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.51 sec) ... Read More

Fetch date record that equals today in MySQL

AmitDiwan

AmitDiwan

Updated on 04-Oct-2019 07:12:11

107 Views

For this, compare the date records with the current date using the CURDATE() method. Let us first create a table −mysql> create table DemoTable (    RegistrationLastDate datetime ); Query OK, 0 rows affected (0.61 sec)Let’s say the current date is −2019-09-03Insert some records in the table using insert command ... Read More

Advertisements