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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:24:44+00:00 2026-06-03T09:24:44+00:00

How can I joining two tables with different column in SQL Server CE? I

  • 0

How can I joining two tables with different column in SQL Server CE?

I have two tables:

Table Schedule

+-----+----------+------+
+ ID  + Name     + Type +
+-----+----------+------+
+ 1   + A        + 1    +
+ 2   + B        + 1    +
+ 3   + C        + 2    +
+-----+----------+------+

Table Description

+-----+--------------------+
+ ID  + Description        +
+-----+--------------------+
+ 1   + A1 - XXXXX         +
+-----+--------------------+

And what I want to get is the table like:

+-----+----------+-----------------+
+ ID  + Name     + Description     +
+-----+----------+-----------------+
+ 1   + A        + A1 - XXXXX      +
+ 2   + B        + -               +
+ 3   + C        + -               +
+-----+----------+-----------------+

Where the Description column should be filled in by - when the ID is not on the Description table.

I tried this code:

SELECT S.ID, D.Description 
FROM Schedule AS S 
INNER JOIN Description AS D

But resulted in:

+-----+----------+-----------------+
+ ID  + Name     + Description     +
+-----+----------+-----------------+
+ 1   + A        + A1 - XXXXX      +
+ 2   + B        + A1 - XXXXX      +
+ 3   + C        + A1 - XXXXX      +
+-----+----------+-----------------+

And when I tried to give ON Clause:

SELECT S.ID, D.Description 
FROM Schedule AS S 
INNER JOIN Description AS D ON S.ID = D.ID

It just get the row where the ID is on the Description table, like:

+-----+----------+-----------------+
+ ID  + Name     + Description     +
+-----+----------+-----------------+
+ 1   + A        + A1 - XXXXX      +
+-----+----------+-----------------+

How can I do that?


[UPDATE]

I tried this code and it works:

SELECT  S.ID, S.Name, COALESCE (D.Description, '-') AS Description
FROM Schedule AS S 
LEFT OUTER JOIN Description AS D ON S.ID = D.ID

But now, how can I add a WHERE clause on it (pls see table SCHEDULE above)?

I tried:

SELECT  S.ID, S.Name, COALESCE (D.Description, '-') AS Description
FROM Schedule AS S 
LEFT OUTER JOIN Description AS D ON S.ID = D.ID AND S.Type = '1'

But still get the whole rows.

  • 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-03T09:24:46+00:00Added an answer on June 3, 2026 at 9:24 am

    LEFT OUTER JOIN in SQL Server CE

    You need to use LEFT OUTER JOIN to join the tables Schedule and Description on the key field ID. Also, use COALESCE to replace NULL values in Description column with -

    Script:

    SELECT          S.ID
                ,   S.Name
                ,   COALESCE (D.Description, '-') AS Description
    FROM            Schedule AS S 
    LEFT OUTER JOIN Description AS D 
    ON              S.ID = D.ID
    

    Output:

    Tested in Microsoft SQL Server CE version 4.0.8482.1

    output

    With WHERE clause

    You need add the WHERE clause after the JOINs. If you are planning to having an ORDER BY, it should come after the WHERE clause.

    Script:

    SELECT          S.ID
                ,   S.Name
                ,   COALESCE (D.Description, '-') AS Description
    FROM            Schedule    AS S 
    LEFT OUTER JOIN Description AS D 
    ON              S.ID = D.ID
    WHERE           (S.Type = 1)
    

    Output:

    Tested in Microsoft SQL Server CE version 4.0.8482.1

    output where

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am joining two tables Employee and Wages . Now an employee can have
I have a relatively simple query joining two tables. The Where criteria can be
I have joining two tables,There are hundreds of records in table a and there
I have two tables, one containing a list of different options users can select
I have two tables. The name table have a foreign key named 'categories'. The
I have two mysql tables - a sales table: +----------------+------------------------------+------+-----+---------+-------+ | Field | Type
Can the Application Name passed to SQL Server (via the ADO Connection string) be
I want to perform update operation by joining two different tables. My tables are
If I am joining two tables and the result set will have ambiguous coloumn
Problem I'm joining two tables on postcode. I only have the data for the

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.