Solved

query - combine two into one dataset

Posted on 2011-03-22
5
412 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
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 40

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

937 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

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now