Solved

query - combine two into one dataset

Posted on 2011-03-22
5
429 Views
Last Modified: 2012-05-11
I have to queries...The first shows a main image the second shows a thumb.. how could i combine these into one dataset? The thumb fields could get name with a thumb postfex

      SELECT [IMAGE_NAME],[IMAGE_DATA]
        FROM [Store].[dbo].[Products] P
          LEFT JOIN [Store].[dbo].[Images] I ON p.Product_Image = I.Image_ID  
           WHERE Product_ID = @Product_ID

        
        SELECT [IMAGE_NAME],[IMAGE_DATA]
         FROM [Store].[dbo].[Products] P
          LEFT JOIN [Store].[dbo].[Images] I ON p.Product_Thumb = I.Image_ID  
           WHERE Product_ID = @Product_ID
0
Comment
Question by:vbnetcoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 26

Expert Comment

by:tigin44
ID: 35191342


SELECT [IMAGE_NAME],I1.[IMAGE_DATA],I2.[IMAGE_DATA]
        FROM [Store].[dbo].[Products] P
          LEFT JOIN [Store].[dbo].[Images] I1 ON p.Product_Image = I1.Image_ID  
          LEFT JOIN [Store].[dbo].[Images] I2 ON p.Product_Thumb = I2.Image_ID  
           WHERE Product_ID = @Product_ID

       
0
 
LVL 19

Expert Comment

by:Rikin Shah
ID: 35191387
SELECT [IMAGE_NAME],[IMAGE_DATA]
FROM [Store].[dbo].[Products] P
LEFT JOIN [Store].[dbo].[Images] I ON p.Product_Image = I.Image_ID  
LEFT JOIN [Store].[dbo].[Images] I ON p.Product_Thumb = I.Image_ID  
WHERE Product_ID = @Product_ID
0
 

Author Comment

by:vbnetcoder
ID: 35191507
I have a thumb image AND a main image, Product_Image is the id for the main image and Product_Thumb is the image for the sub...

This dataset needs to show BOTH

So, i shoulid have 2 [IMAGE_NAME] AND [IMAGE_DATA] fielld one for the main and one for the thumb
0
 
LVL 41

Accepted Solution

by:
Sharath earned 500 total points
ID: 35191947
you mean this?
SELECT I1.[IMAGE_NAME] Main_Image_Name, 
       I1.[IMAGE_DATA] Main_Image_Data, 
       I2.[IMAGE_NAME] Sub_Image_Name, 
       I2.[IMAGE_DATA] Sub_Image_Data 
  FROM [Store].[dbo].[Products] P 
       LEFT JOIN [Store].[dbo].[Images] I1 
         ON p.Product_Image = I.Image_ID 
       LEFT JOIN [Store].[dbo].[Images] I2 
         ON p.Product_Thumb = I.Image_ID 
 WHERE P.Product_ID = @Product_ID

Open in new window

0
 

Author Closing Comment

by:vbnetcoder
ID: 35192067
ty
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question