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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:26:36+00:00 2026-06-15T13:26:36+00:00

My table IncomingLetter has a foreign key to a table Department, which has an

  • 0

My table IncomingLetter has a foreign key to a table Department, which has an ID and a column Short_Name.

I’m using this query to count the incoming letters assigned to a department.

SELECT COUNT(DocumentNumber) AS TotalNumberIncomingLetters
FROM IncomingLetter
WHERE Assigned_To_Department=1;

Whereas this works I want to make a query based upon the short name and not based upon the ID.

SELECT COUNT(DocumentNumber) AS TotalNumberIncomingLetters
FROM IncomingLetter
WHERE Assigned_To_Department.Short_Name="My Department Name";

This does not work, whereas I found examples that are using this syntax. However, it is probably important to notice, that I m using this query in MS access.

  • 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-15T13:26:38+00:00Added an answer on June 15, 2026 at 1:26 pm

    You should use

    SELECT COUNT(il.DocumentNumber) AS TotalNumberIncomingLetters
    FROM IncomingLetter il
     INNER JOIN Department d on d.ID = il.Assigned_To_Department
    WHERE d.Short_Name="My Department Name";
    

    The “My Department Name” text is actually stored in the Departments table, and only the number (1) is stored in the IncomingLetter table, in the field Assigned_To_Department.
    Asking for Assigned_To_Department.Short_Name basically asks the number 1 to get it’s Short_Name field, that does not make sense.

    You need to tell the database engine two things in these scenarios:

    • which tables are connected – IncomingLetter and Departments in this case (the inner join part)
    • how they are connected – by setting their Assigned_To_Department and ID fields respecively (the on ... part
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table IMAGES : columns- imageID, Image, and categoryID*(this being the foreign key) Table CATEGORIES
Table has surrogate primary key generated from sequence. Unfortunately, this sequence is used for
table : id (integer primary key) data (blob) I use mysql and sqlalchemy. To
Table A has two columns: ID and name I want to input 3 ID
Table Structure: I Tried this: select Id, Name from Color where ParentId=4 UNION select
Table: Relatives emp_id dep_id (composite primary key) We have to restrict one employee to
Table (ipvote) Table (pictures) What is the SQL query to retrieve all the images
Table - user_feed column name - date_n_time (type - datetime) How do I write
(Table)File has many (Table)Words FK Words.file_id related to a single File.id Default value of
//Table select $(#reports-table tr).click( function() { var detail_id = $(this).attr('id'); $(this).addClass(selected); $(this).siblings().removeClass(selected); $('#reports-right').show().load('/members/details/'+detail_id); $('#reports-table').width(680);

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.