Advertisement

02.27.2008 at 10:27AM PST, ID: 23197903
[x]
Attachment Details

SQL: Query a value in Table1, use *the* result to query a result set in Table2

Asked by rfwoolf in Data Manipulation, MySQL, Data Mining

I need to know how to do this in SQL.

Below you will find the two tables and some examples of the results I want.

Basically I will have a user input like "Vehicles", and I will need it to
1) Find "Vehicles" in the field "CATEGORY DESCRIPTION"  [RECORD3]
2) Get its "CATEGORY CODE" [VEH]
3) SELECT all records in TABLE2 with the "CATEGORY CODE" = "VEH"Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
===TABLE 1===
 FIELDS: CATEGORY DESCRIPTION  | CATEGORY CODE
RECORD1: Furniture               FRNTR
RECORD2: Foodstuffs              FOOD
RECORD3: Vehicles                VEH
 
===TABLE 2===
 FIELDS: SUBCATEGORY DESCRIPTION  | CATEGORY CODE
RECORD1: Tables                     FRNTR
RECORD2: Chairs                     FRNTR
RECORD3: Sedans                     VEH
RECORD4: Trucks                     VEH
RECORD5: Bikes                      VEH
 
Example 1: If the user inputs "Vehicles", I want Records 3-5 of TABLE 2.
Example 2: If the user inputs "Furniture", I want Records 1-2 of TABLE 2.
[+][-]02.27.2008 at 10:55AM PST, ID: 20997101

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Data Manipulation, MySQL, Data Mining
Sign Up Now!
Solution Provided By: angelIII
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906