Solved

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

Posted on 2011-09-05
1
225 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
1 Comment
 
LVL 59

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Loading csv or delimited data files to MySQL database is a very common task frequently questioned about and almost every time LOAD DATA INFILE comes to the rescue. Here we will try to understand some of the very common scenarios for loading data …
This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now