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 8497771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:13:15+00:00 2026-06-11T00:13:15+00:00

We have two tables one with ids and one with names. Some id’s are

  • 0

We have two tables one with ids and one with names. Some id’s are not required (are nullable) for example :

rowId item1Id, item2Id, item3Id (item3Id can be null)

After we join this two tables we get id’s and names. But if item3 Id is null that row is not shown.

Some data:

Table1

rowId, item1Id, item2Id, item3Id

1, 2, 3, 4

2, 1, 5, NULL

In our case we get as result one row ( 1 row)

So if it’s null than it doesnt exists in Table2 and the row is not shown, but we would like to display null.
So when we left join these two tables the result should have 2 rows.

This is the sql :

SELECT Recipes.recipeId, Recipes.userId,Users.firstName + ' ' + Users.lastName as userName,  servingTypeId,
Codings.coding as servingType, categoryId, Codings_2.coding as healthAspects, continentId,
Codings_3.coding as continent, countryId, CodingsAssociated.coding as country, typeOfPreparationId,
Codings_4.coding as typeOfPreparation, flavourId, Codings_5.coding as flavour, preparationSkillId,
Codings_6.coding as preparationSkill, seasonId,  activePreparationTime,
overallPreparationTime, isLocalDelight, servings, Codings_7.coding as season ,
calories, youTubeId, datePosted, isComposite, Recipes.isApproved, Recipes.timestamp, title,
localDelightRegion, otherFeatures, cookingInstructions 
      FROM Recipes LEFT OUTER JOIN

      Codings ON Recipes.servingTypeId = Codings.codingKeyId LEFT OUTER JOIN
      Codings as Codings_2 ON Recipes.categoryId = Codings_2.codingKeyId LEFT OUTER JOIN
      Codings as Codings_3 ON Recipes.continentId = Codings_3.codingKeyId LEFT OUTER JOIN
      CodingsAssociated ON Recipes.countryId = CodingsAssociated.codingKeyId LEFT OUTER JOIN
      Codings as Codings_4 ON Recipes.typeOfPreparationId = Codings_4.codingKeyId LEFT OUTER JOIN
      Codings as Codings_5 ON Recipes.flavourId = Codings_5.codingKeyId LEFT OUTER JOIN
      Codings as Codings_6 ON Recipes.preparationSkillId = Codings_6.codingKeyId LEFT OUTER JOIN
      Codings as Codings_7 ON Recipes.seasonId = Codings_7.codingKeyId  LEFT OUTER JOIN
      RecipesTranslations ON Recipes.recipeId = RecipesTranslations.recipeId LEFT OUTER JOIN
      Users ON Recipes.userId = Users.userId

      WHERE CodingsAssociated.languageId = @languageId AND Codings.languageId = @languageId
      AND Codings_2.languageId = @languageId AND Codings_3.languageId = @languageId
      AND Codings_4.languageId = @languageId AND
      Codings_5.languageId = @languageId AND Codings_6.languageId = @languageId AND RecipesTranslations.languageId = @languageId
      AND Codings_7.languageId = @languageId

For example because seasonId is sometimes null the join for Codings_7.coding is not shown, but I won`t to show also these rows where ids are null that the name also be null.

  • 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-11T00:13:17+00:00Added an answer on June 11, 2026 at 12:13 am

    As stated by Nikola Markovinović you need to move the where conditions to the join conditions

    here your select corrected:

    SELECT
       Recipes.recipeId,
       Recipes.userId,
       ---
       cookingInstructions 
    FROM
       Recipes
       LEFT OUTER JOIN Codings ON
          Recipes.servingTypeId = Codings.codingKeyId AND
          Codings.languageId = @languageId
       LEFT OUTER JOIN Codings as Codings_2 ON 
          Recipes.categoryId = Codings_2.codingKeyId AND
          Codings_2.languageId = @languageId
       LEFT OUTER JOIN Codings as Codings_3 ON
          Recipes.continentId = Codings_3.codingKeyId AND
          Codings_3.languageId = @languageId
       LEFT OUTER JOIN CodingsAssociated ON
          Recipes.countryId = CodingsAssociated.codingKeyId AND
          CodingsAssociated.languageId = @languageId 
       LEFT OUTER JOIN Codings as Codings_4 ON
          Recipes.typeOfPreparationId = Codings_4.codingKeyId AND
          Codings_4.languageId = @languageId
       LEFT OUTER JOIN Codings as Codings_5 ON
          Recipes.flavourId = Codings_5.codingKeyId AND
          Codings_5.languageId = @languageId
       LEFT OUTER JOIN Codings as Codings_6 ON
          Recipes.preparationSkillId = Codings_6.codingKeyId AND
          Codings_6.languageId = @languageId
       LEFT OUTER JOIN Codings as Codings_7 ON
          Recipes.seasonId = Codings_7.codingKeyId AND
          Codings_7.languageId = @languageId
       LEFT OUTER JOIN RecipesTranslations ON
          Recipes.recipeId = RecipesTranslations.recipeId AND
          RecipesTranslations.languageId = @languageId
       LEFT OUTER JOIN Users ON
          Recipes.userId = Users.userId ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables in Sql Server, one containing IDs for files and the
I have two tables, one of which matches ids to ratings and one of
I have 2 tables, one with a infinite list of Names and IDs. The
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables one called fs_note the other called dumy_fs_note I created after
i have two tables one is called addons and holds information about different addons,
I have two tables : one table it matchs and the other is teams.
I have two tables connected with one to many relationship. Parent Table is a
I have two tables that link together through an id one is submit_moderate and
I have two tables and their only difference is one column is missing from

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.