Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
kamal1910
Starting Member
3 Posts |
Posted - 2011-01-31 : 08:39:17
|
table: Test1Id Styleno StyleName1 001 blue2 002 redtable: Test2Id image_id Image_name 1 0001 img1_0012 0002 img2_0013 0003 img1_0024 0004 img2_002For table Test1 is containg the two style names. Each style name should conatin three images (img1, img2, img3) in Test2 table. But now the table is containg img1 and img2 for two styles. img3_001 & img3_002 images are missing in Test2. I want to disply the missing images to admin. I want the below result.ImageName Statusimg1_001 Yesimg2_001 Yesimg1_002 Yesimg2_002 Yesimg3_001 Noimg3_002 NoPls help me.kamalakannan |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-01-31 : 08:49:47
|
Show us what you have so far and then we can help you. Not many people on this site will do your homework for you, but all would be more than glad to help you with it after a little effort on your part.JimEveryday I learn something that somebody else already knew |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2011-01-31 : 08:51:52
|
Which table are img3_001 & img3_002 images records saved?PBUH |
 |
|
kamal1910
Starting Member
3 Posts |
Posted - 2011-01-31 : 08:56:03
|
I will need a report for admin to know what are all the images are missing in table Test2. I am not given the exact scenario, i gave the core of my task. img3_001 & img3_002 images should be in Test2, but it is missing, i will give the below result to admin, and admin know ok...img3_001 & img3_002 images are missing, then they will upload these images into this Table Test2 from application.ImageName Statusimg1_001 Yesimg2_001 Yesimg1_002 Yesimg2_002 Yesimg3_001 Noimg3_002 Nokamalakannan |
 |
|
ZZartin
Starting Member
30 Posts |
Posted - 2011-01-31 : 18:32:17
|
Have you tried something with an outer join between table 1 and table 2? |
 |
|
Sachin.Nand
2937 Posts |
Posted - 2011-02-01 : 03:31:55
|
quote: Originally posted by kamal1910 I will need a report for admin to know what are all the images are missing in table Test2. I am not given the exact scenario, i gave the core of my task. img3_001 & img3_002 images should be in Test2, but it is missing, i will give the below result to admin, and admin know ok...img3_001 & img3_002 images are missing, then they will upload these images into this Table Test2 from application.ImageName Statusimg1_001 Yesimg2_001 Yesimg1_002 Yesimg2_002 Yesimg3_001 Noimg3_002 Nokamalakannan
How will the query know that img3_001 & img3_002 are missing when there are no refrences for it ?PBUH |
 |
|
kamal1910
Starting Member
3 Posts |
Posted - 2011-02-01 : 04:04:57
|
Yes, that is in different table. Table : Test3ID ImageName1 Img12 Img23 Img3Based on the above table, we come to know.. Img3 is missing for bi=oth styles numbers 001, 002..kamalakannan |
 |
|
matty
Posting Yak Master
161 Posts |
Posted - 2011-02-01 : 05:59:36
|
[code]SELECT t.ImageName, CASE WHEN t2.Image_name IS NULL THEN 'No' ELSE 'Yes' END AS StatusFROM( SELECT a.ImageName + '_' + b.Styleno AS ImageName FROM Test3 a CROSS JOIN Test1 b) tLEFT JOIN Test2 t2 ON t.ImageName = t2.Image_name[/code] |
 |
|
|
|
|
|
|