Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-05
1
Medium Priority
?
243 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 2000 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

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

705 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