Solved

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

Posted on 2011-09-05
1
234 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Showing random records from database 10 54
Creating Functions in phpMyAdmin 8 61
Using Modal's in to Retrieve Data from MySql and Populate Forms 13 145
Mysql query one to many 11 42
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 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