DO YOU NEED A CONTENT WRITER FOR YOUR BUSINESS?

Your One-Stop Solution for All Content Needs! Click here for more!
Categories: MySQL

IF statement in MySQL stored procedures

Share

If statement allows you to execute a set of SQL statements based on condition. If certain condition returns true then statement executes, otherwise not.

Example:

DELIMITER $$
CREATE PROCEDURE MyifCond()
BEGIN
DECLARE x  INT;
SET x = 1;
SET y = 1;
WHILE x  <= 10 DO
SET  x = x + 1;
IF x > 5 THEN
SET  y = y + 1;
END IF;
END WHILE;
SELECT y;
END$$
DELIMITER;
Namaste UI

For any types of queries, you can contact us on info[at]namasteui.com.

Recent Posts

A Guide To CPQ and How It Fuels Marketing and Sales

Sales and marketing teams help attract, convert, and retain customers to ensure an organization’s long-term…

7 days ago

Top Questions Asked About Invoice Financing Applications

Are you an owner of a small business who’s trying to come up with ways…

2 weeks ago

Complete Medical Guide to Blood Sugar Testing and Glucose Control

Introduction When patients bring me their lab reports, the confusion is almost always the same.…

2 weeks ago

6 Tips to Strategically Remodel Your Home

Are you excited about remodeling your house after a long time? Perhaps if you're planning…

2 weeks ago

Driving Finding Balance on and off the Mat: How Calm Awareness Supports Everyday

The practice of yoga teaches us to be present, patient and mindful of our decisions.…

2 weeks ago

7 Things to carry with you on hill station

As we are once again allowed to go outside, nearly everyone is planning to go…

3 weeks ago