Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8460173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:31:57+00:00 2026-06-10T13:31:57+00:00

I have these 2 queries that almost give me the data I need: SELECT

  • 0

I have these 2 queries that almost give me the data I need:

SELECT  Products.ItemID, Products.ItemID + '-' + ModifierListItems.ItemID AS SizeItemID
FROM         ModifierLists INNER JOIN
                      ProductModifierLists ON ModifierLists.ModifierListID = ProductModifierLists.ModifierListID INNER JOIN
                      ModifierListItems ON ModifierLists.ModifierListID = ModifierListItems.ModifierListID INNER JOIN
                      Products ON ProductModifierLists.ItemID = Products.ItemID AND ProductModifierLists.ManufacturerID = Products.ManufacturerID
WHERE     (Products.ManufacturerID = 262) AND ModifierListName='Size'
ORDER BY Products.ItemID

SELECT  Products.ItemID, ModifierListItems.ItemID AS ColorItemID
FROM         ModifierLists INNER JOIN
                      ProductModifierLists ON ModifierLists.ModifierListID = ProductModifierLists.ModifierListID INNER JOIN
                      ModifierListItems ON ModifierLists.ModifierListID = ModifierListItems.ModifierListID INNER JOIN
                      Products ON ProductModifierLists.ItemID = Products.ItemID AND ProductModifierLists.ManufacturerID = Products.ManufacturerID
WHERE     (Products.ManufacturerID = 262) AND ModifierListName='Color'
ORDER BY Products.ItemID

The final output I am looking for is the SizeItemID concatenated with the ColorItemID joined on the ItemID.

Sample results of the 2 queries:

ItemID    SizeItemID
-------   ----------
A          A-S
A          A-M
B          B-M
B          B-L

ItemID     ColorItemID
-------    -----------
A            BLK
A            WHT
B            BLK
B            WHT
B            GRN

The results I am looking for would be the following:

FinalItemID
-----------
A-S-BLK
A-S-WHT
A-M-BLK
A-M-WHT
B-M-BLK
B-M-WHT
B-M-GRN
B-L-BLK
B-L-WHT
B-L-GRN
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:31:58+00:00Added an answer on June 10, 2026 at 1:31 pm

    You can take your two queries and join them together on ItemId to construct the final value.

    In the following query, I also use aliases on your table names. Many people find meaningful aliases easier to read than long table names:

    with tsize as (
         SELECT p.ItemID,
                p.ItemID + '-' + mli.ItemID AS SizeItemID
         FROM ModifierLists ml INNER JOIN
               ProductModifierLists pml 
               ON ml.ModifierListID = pml.ModifierListID INNER JOIN
               ModifierListItems mli
               ON ml.ModifierListID = mli.ModifierListID INNER JOIN
               Products p
               ON pml.ItemID = Products.ItemID AND
                  pml.ManufacturerID = p.ManufacturerID
         WHERE (p.ManufacturerID = 262) AND ModifierListName='Size'
        ),
         tcolor as (
         SELECT  p.ItemID, mli.ItemID AS ColorItemID
         FROM ModifierLists moli INNER JOIN
              ProductModifierLists pml
              ON ml.ModifierListID = pml.ModifierListID INNER JOIN
              ModifierListItems mli
              ON ml.ModifierListID = mli.ModifierListID INNER JOIN
              Products p
              ON pml.ItemID = Products.ItemID AND
                 pml.ManufacturerID = p.ManufacturerID
         WHERE     (Products.ManufacturerID = 262) AND ModifierListName='Color'
        )
    select SizeItemID+'-'+ColorItemID
    from tsize join tcolor
        on tsize.itemid = tcolor.ItemID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these queries: SELECT a.Id, a.Name, (SELECT COUNT(Id) FROM b WHERE b.IdTableA =
I have these 2 queries that I would like to combine into one big
I have these two queries to test my output SELECT DISTINCT( providerId ), SUM((
I have a right outer join, that almost does what I want... SELECT users_usr.firstname_usr,
I have two queries: <cfquery name=getChairReview datasource=#application.dsn#> SELECT* FROM eval_reviews WHERE faculty = <cfqueryparam
I have about 4 or 5 different queries that are all exactly like with
I'm working at a helpdesk application where i have a standalone script that queries
I have basically MySQL dump from a WordPress database with some data. The whole
I have almost solved this quadrant queries problem of Interviewstreet using segment trees with
I have an app that queries the MediaStore and shows all the images in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.