Jump to content

help constructing a query


skaterdav85

Recommended Posts

I have 2 tables. Table 1 has the following fields:skateboard_name, wheel1ID, wheel2ID, wheel3ID, wheel4ID.and Table 2 called "Wheels" contains the fields:wheel_ID, brand, bearingEach wheelID in Table 1 relates to the wheel_ID field in Table 2. How would I construct a query that pulls the brand, so my results would look something like this?skateboard_name, brand (for wheel1ID), brand (for wheel2ID), brand (for wheel3ID), brand (for wheel4ID)

Link to comment
Share on other sites

You need to use a join, actually you'll need one join per wheel field. Look up using inner joins with table aliases, e.g.:SELECT s.skateboard_name, w1.brand, w2.brand, w3.brand, w4.brand FROM skateboards AS s INNER JOIN wheels AS w1 ...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...