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 |
|
lio1972
Starting Member
19 Posts |
Posted - 2012-08-01 : 10:59:10
|
| Hi everione.This query suppost to return one row ,but returns zeroWhat I am doing wrongSELECT recipe.id,recipe.name, recipe.posted_by, recipe_images.image_link, recipe_video.videoFROM recipeJOIN recipe_images ON recipe.id = recipe_images.idJOIN recipe_video ON recipe.id = recipe_video.idWHERE recipe.id=4; |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-08-01 : 11:13:00
|
May be not all recipies have a video and an image. You can find out for this specific case by running these queries. In each case, it has to return at least one row if you are to get any output in your query.SELECT * FROM recipe WHERE id = 4;SELECT * FROM recipe_images WHERE id = 4;SELECT * FROM recipe_video WHERE id = 4; If that is not the case, change the JOINs to LEFT JOINs. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-01 : 11:16:03
|
| may be relationship specified is wrongunless we see some sample data and have an idea of what you're trying to do we can only guess!------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
lio1972
Starting Member
19 Posts |
Posted - 2012-08-01 : 11:38:13
|
| Thank you for the help ,the problem was that there was no video with id 4Thank you again |
 |
|
|
|
|
|