VLookup equivalent MySQL multiple criteria

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • garjones
    New Member
    • Jun 2012
    • 1

    VLookup equivalent MySQL multiple criteria

    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|S LA|Cost
    London|Small|Ec onomy|5000
    London|Medium|E conomy|6000
    London|Large|Pr emium|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_COMPONENT S

    Component|Locat ion|Size|SLA
    A|Singapore|Sma ll|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_COMPONENT S or create another temp table.

    Hope that's clear. Thanks a lot.

    Gareth
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    Working...