Solved

How to use the look-up value from another look up table?

Posted on 2011-09-05
1
236 Views
Last Modified: 2012-08-14

I want to have a script in the procedure to quickly get the version number from the Version table below by inputing the value number, and execute corresponding module:

If version is "1.1" THEN run module 1
If Version is "1.2" THEN run module 2

Table Version:
Value  Version
1      1.1
2      2.0

Thanks a lot.
0
Comment
Question by:heyday2004
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 60

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 36488310
Hi.

First, if you have not created a procedure before, here is the reference:
http://dev.mysql.com/doc/refman/5.5/en/create-procedure.html

Then you can get version into a variable like so:

DECLARE version_variable VARCHAR(10);
SELECT `Version` 
INTO version_variable
FROM `Version`
WHERE `Value` = value_variable;

Open in new window


Using that variable, the structure of IF statement could look like this:
IF (condition 1) THEN
   -- do one thing
ELSEIF (condition 2)
   -- do something else
ELSE
   -- do something as default
END IF;

Open in new window


Let's see if you can put together what you need from that. You can post back if you have any difficulties, but this way you should get a better understanding.

Hope that helps.

Kevin
0

Featured Post

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question