By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,117 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,117 IT Pros & Developers. It's quick & easy.

VLookup equivalent MySQL multiple criteria

P: 1
Hi everyone, first post so thanks in advance.

I have been trawling sites for 2 days trying to find the answer to this so apologies if I missed something (MySQL newbie!).

I have a table of reference data that presents a standard cost based on 3 criteria, example data shown below:

TABLE_COSTS

Location|Size|SLA|Cost
London|Small|Economy|5000
London|Medium|Economy|6000
London|Large|Premium|10000
Singapore|Small|Economy|4000
(note this is a sample, there are many more combos)

And I have a another table with a list of components that can have any combo of the first three columns as criteria i.e.

TABLE_COMPONENTS

Component|Location|Size|SLA
A|Singapore|Small|Economy
B|London|Small|Economy
C|London|Large|Premium
etc

Here's the challenge. I need to identify the cost associated with each component and ideally store it as an additional column in the TABLE_COMPONENTS or create another temp table.

Hope that's clear. Thanks a lot.

Gareth
Jun 6 '12 #1
Share this Question
Share on Google+
1 Reply


Rabbit
Expert Mod 10K+
P: 12,359
You posted in the wrong forum. MS SQL Server is not MySQL. I have moved your thread.

User an Inner Join on the tables on the three fields. Don't store the price twice, there's no need to. You can just join the tables whenever you need to get the price.
Jun 6 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.