Using conditional expressions inside MySQL Stored Procedure

Sometimes there is need to use conditional expression inside stored procedure to control the flow of execution.We can use IF or CASE statements for this.Below is a stored procedure to check the performance of a student based on its score.Store the below stored procedure in a file called get_performance.sqlDELIMITER $$DROP PROCEDURE IF EXISTS get_performance$$CREATE PROCEDURE get_performance    (score NUMERIC(8, 2),    OUT result VARCHAR(11))BEGIN    IF (score >= 90) THEN        SET result = ‘OUTSTANDING’;    ELSEIF (score >= 70 AND score < 90) THEN        SET result = ‘AWESOME’;    ELSEIF (score >= 60 AND score < 70) THEN        SET result = ‘GOOD’;    ELSEIF (score >= 40 AND score < 60) THEN    SET result = ‘OK’;    ELSE    SET result = ‘FAIL’;    END IF;END$$DELIMITER ;Execute the procedure:mysql> SOURCE get_performance.sql;Query OK, 0 rows affected, 1 warning (0.00 sec)Query OK, 0 rows affected (0.00 sec)Execute the call:mysql> CALL get_performance(67, @result);Query OK, 0 rows affected (0.00 sec)mysql> SELECT @result;+———+| @result |+———+| GOOD    |+———+1 row in set (0.00 sec)Basically IF, ELSEIF check for conditions, ELSE matches any condition which has not been matched by any preceding condition and finally THEN executes the set of statements for the satisfied condition and breaks out of the conditional expression. Similarly, we can use CASE for switching to statement sections based on equality comparison with a set of unique values.
via Planet MySQL
Using conditional expressions inside MySQL Stored Procedure

Use of loops in MySQL stored procedures

Loops -> Repetitive tasks3 types of loops in MySQL stored program: – Simple loop using LOOP and END LOOP clauses- WHILE and END WHILE clauses that runs while a condition is true- REPEAT  and UNTIL clauses that runs until a condition is trueTermination of loop -> LEAVE statement.I will demonstrate the use of loops the simple loop way.Simple counter from 1 to 10:Store below stored procedure in a file named my_loop.sqlDELIMITER $$DROP PROCEDURE IF EXISTS my_loop$$CREATE PROCEDURE my_loop()BEGIN    DECLARE counter INT DEFAULT 0;    my_loop: LOOP        SET counter = counter + 1;        IF counter = 10 THEN            LEAVE my_loop;        END IF;    END LOOP my_loop;    SELECT CONCAT(‘Done counting up to ‘, counter) AS result;END$$DELIMITER ;Execute the stored procedure:mysql> SOURCE my_loop.sqlQuery OK, 0 rows affected, 1 warning (0.00 sec)Query OK, 0 rows affected (0.00 sec)mysql> CALL my_loop();+————————+| result                 |+————————+| Done counting up to 10 |+————————+1 row in set (0.00 sec)Query OK, 0 rows affected (0.00 sec)Explaining simply, we are defining a counter that starts with 0 and a LOOP labelled my_loop that increments from 0 onward and a condition inside to check for counter value of 10, when the loop terminates through the use of LEAVE clause. You can give a try to the other loop clauses 🙂
via Planet MySQL
Use of loops in MySQL stored procedures

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Your office is your home away from home, and keeping the office clean is very important to your everyday work life. While it’d be great if you could clean up everyday, simply giving the appearance that things are organized can help you not look like an absolute slob.

This post originally appeared on GetVoIP.

The truth is that you’ll probably hold off on the bigger cleaning chores until you absolutely need to—that us, until somebody important knocks on the door, forcing you to de-clutter everything like a highly-efficient cleaning ninja. But keeping just a little order will go a long way.

Here are ten things you can do so your office looks good when you need it to.

Keep Your Desk Clear

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

This is the most obvious thing to do—and the most difficult. I know you want your funny coffee mugs and printer user guides and rogue pen caps on your desks and ready to be utilized at a moment’s notice. But do you really need them there? Probably not.

What you should do: So clear off the desk top surface before people walk in to visit your office. Find anyplace that can accommodate all that junk stuff. And then, most importantly, pretend like it was always that clean to begin with.

Keep A Catch-All Drawer

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

You need a quick place to stash those funny coffee mugs, printer user guides, and rogue pen caps that were sitting on your desk. This is where your catch-all drawer comes to the rescue. Otherwise known as a junk drawer.

What you should do: Keep one desk drawer available to quickly store away any unwanted stuff from off the top of your desk. If the mess is out of sight, you can keep up the appearance that you’re a clean freak. Obviously, remember to clean that drawer often, or else you’ll end up with another mess on your hands.

Let Some Light In

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Sometimes, all the fluorescent lamps in the world can’t make your office look as pleasant as you want it to. And for that, there’s always the window.

What you should do: Open the blinds and let some light peek into the room so that your visitors don’t have to talk to you in the dark. Maybe even crack the window open a little if the ventilation can help.

Hide All Your Cables

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Few things are more distracting than computer cables and other wires dangling around the back of your desk as if you’re housing NSA mainframes in your office. If you’re not housing NSA mainframes in your office, then do without that clutter.

What you should do: Run all the cables through your desk’s grommet and under your desk so that it’s out of sight for anybody walking into your office. If you need the help, make use of colored cable ties to better organize those pesky cables.

Get Some Plants

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Nothing is more inviting than a couple of beautiful plants to spice up your office feng shui. Not only does it add some pizzazz to your room, but it also makes people think you’re not weird for cracking open the window for air and sunlight on occasion.

What you should do: Get a plant or two that work with the colors and accents of your room. Don’t go over-the-top here—it’s still an office, after all. But understand that good-looking plant life can be an excellent distraction from the rest of your room.

Close Unnecessary Computer Applications

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Keeping your digital workspace clean will be helpful too. This is pretty straight-forward. You should be working, not playing Counterstrike, ordering a car stereo, and doing virus scans—all at the same time. And, let’s face it, you don’t want to be distracted by irrelevant apps and games on your computer screen when your boss happens to be in the room.

What you should do: Close whatever applications you don’t need to be staring at so that you don’t have to get called out for it by your office visitor. Prioritize the tasks you do work on over the course of the day so that you’re not doing 100 things at once and crushing your system memory, either.

Keep The Furniture Clean

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

If you’ve got office furniture, chances are they’ve collected dust or need cleaning on occasion, too. But in a pinch? That space behind the office couch can become your go-to storage space for anything you want to quickly hide from view.

What you should do: The best bet here is to keep that furniture clean at all times, but make use of the space behind it when you need to. Sometimes, flinging some paper behind the couch is easier than picking up the paper and walking it to a garbage pail.

Don’t Eat Messy Food At Your Desk

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Whatever you do, don’t bring that incredibly messy triple-layered spicy bean lathered burrito into the office. Not only does that sound regrettable, but it will end up leaving a mess.

What you should do: If you do eat messy food at your desk, use some Febreeze afterwards to neutralize the odors in the air. And wipe down anything that’ll make people regret visiting your room.

Put A Lid On Your Garbage Can

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Nobody wants to see your trash. And, if you’re one of those messy burrito eaters, nobody wants to smell your trash, either.

What you should do: Get a garbage bin with a lid on it to at least mitigate the sight and smell of piling up trash. But remember to have that trash taken care of frequently so that the room is as fresh as it can be—until your next messy burrito.

Keep The Floor Clear

Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Because you never know when an impromptu dance session will strike. Just remember to toss out any kazoos and streamers when you’re done. And hide that boom box, too. This isn’t the ’90s.

What you should do: If you happen to have a small vacuum, use it a few times a week to make sure your office floor looks as good as the day you walked in there. While you may know how best to navigate your office floor, remember that other people need to walk in there, too. And, often, it’s the first thing they notice when they step foot inside your office.

Sometimes, you need to go above-and-beyond relying on the after-hours office cleaning workers to make sure your office looks its best—and of course if its your home office, the responsibility is all yours. Always remember that keeping the room clean during the day is the best option, but if you can’t do that, you can be sneaky about it, too. And that part’s always fun.

10 Simple Ways To Make Your Office Look Cleaner Than It Really Is | GetVoIP


Charles Samuel is Senior Editor at GetVoIP. When he’s not writing, he’s making music, doing graphic design work, or managing his blog. He is interested in all forms of geekery, including, but not limited to, technology and discussions about Firefly.

Illustration by Karnoff (Shutterstock). Photos by Mingo Hagen, Bryan Ledgard, Jeremy Levine, Tim Moreillon, Nick Richards, Jean-Baptiste Lebrune, Donnie Ray Jones, Michael Bentley, Dave Friedel (Flickr).

Want to see your work on Lifehacker? Email Andy.


via Lifehacker
Ten Simple Ways to Make Your Office Look Cleaner Than It Really Is

Explore Portugal In This Scenic Hyperlapse Made By An Award Winning Timelapse Filmmaker

While on a holiday in Portugal, Spain to accept a Best Timelapse award for his incomparably brilliant Moscow Night Timelapse/Hyperlapse, Kirill Neiezhmakov, like any good photographer, seized the opportunity to create his next treasure, Portugal Hyperlapse/Timelapse. Neiezhmakov is making a name for himself among timelapse and hyperlapse photography enthusiasts as one of the art forms leading […]

The post Explore Portugal In This Scenic Hyperlapse Made By An Award Winning Timelapse Filmmaker appeared first on DIY Photography.


via DIYPhotography.net -Hacking Photography, One Picture At A Time
Explore Portugal In This Scenic Hyperlapse Made By An Award Winning Timelapse Filmmaker

Make Siri Better By Telling Her All About Your Relationships

Make Siri Better By Telling Her All About Your Relationships

If you really want to be able to emulate the characters in Apple’s promotional videos then you need to be able to tell Siri to "call mom" and "email dad." Thanks to the custom label field built into iCloud contacts, you can assign any kind of relationship to people you know. Tell Siri about your best friend, your boss, and your arch-enemy and you can control the virtual assistant more easily with your voice.

Activate Siri with a long press on the Home button to tell her (or him) about the relationships you have with your contacts: "Dave is my brother," "Amy is my mother-in-law," and so on. A confirmation screen appears where you can double-check the app has understood your command correctly and pick between similarly-named contacts when applicable.

If you want to throw some nicknames or pet names into the mix, then Siri can cope with these too. Everything from "my oldest friend" to "my editor" is saved in your own contact card, where you can edit and remove labels as required. You can even specify relationships between contacts other than yourself, like Steve’s mom, etc. Just beware that if you’re syncing contacts through Google Contacts or Microsoft Exchange, some of these custom labels may be lost. So just make sure you don’t forget who your mom is.

via Gizmodo
Make Siri Better By Telling Her All About Your Relationships

Make More Money at Garage Sales by Not Pricing Items

Make More Money at Garage Sales by Not Pricing Items

Garage sales are a great way to pare down your excess stuff and make some quick cash in the process. However, you can make more money with a few little tricks. For example, consider not pricing your items to get more cash for them.

Lynda Hammond of GarageSaleGal tells the Today.com:

A lot of times you will get more money if you don’t price stuff. Maybe you have an old chef’s cookie jar you’ve always hated and would take a buck for it. But, maybe the buyer has been looking for that and would name a higher price.

This tip surprised me. I’d assume that people would be less willing to buy an item if it didn’t have a price tag. But Hammond makes a good point, and for bigger ticket items, this might give the buyer a chance to throw out the first number. Also, I’ve never been great at garage sales.

For more selling tips, check out the full post below.

Show me the money! 11 ways to make more cash at your next garage sale | Today.com

Photo by Sandra Cohen-Rose and Colin Rose.


Two Cents is a new blog from Lifehacker all about personal finance. Follow us on Twitter here.
via Lifehacker
Make More Money at Garage Sales by Not Pricing Items