Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL query - looking up data from within the current table

$
0
0

Hi guys,

Sorry if this is the wrong place for this - feel free to move it if I've done goofed.

I'm just getting in to SQL & have gotten a bit stuck. Any help you guys could offer would be greatly appreciated.

What I want to do is return the ProductGroupID, then the relevant Name associated with Level1ID, Level2ID, and Level3ID from the ProductGroups table (see attached file). This would be done by picking up the number in each Level#ID field, then looking it up against the ProductGroupID field (e.g. Level1ID = 11, find ProductGroupID 11 & return the contents of the Name field).

For example, if I were looking at ProductGroupID 135, I'd like it to return:

ProductGroupID, Level1ID, Level2ID, Level3ID

135,"Accessories", "Bath & Shower", "Bath or Shower Shelf/Basket"

Hope that all makes sense - it's a bit hard to put in to words!

Cheers


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>