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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:35:11+00:00 2026-06-14T02:35:11+00:00

so here is my issue: i have 3 tables: ROLE : RID ,NAME CLIENT

  • 0

so here is my issue:

i have 3 tables:

  • ROLE : RID ,NAME
  • CLIENT : CID, NAME
  • USER : UID, RID, CID, USERNAME, PASSWORD

Below is the SQL statement that I have written:

SELECT USER.UID,USERNAME,PASSWORD,ROLE.NAME, ROLE.RID 
FROM USER 
INNER JOIN ROLE ON USER.RID=ROLE.RID 
WHERE CID=1;

The above statement is returning only 1 row when there should actually be 2 rows.

I don’t understand what is not working.

When i do the following, i get my 2 rows:
SELECT *
FROM USER
WHERE CID =1;

Note that i am using spring framework and also implementing a RowMapper. Below is my actual code with the field names as per the dbase.

public List<User> viewUserClient(int client_id) {
    String sql =
            "SELECT USER.ID,USERNAME,PASSWORD,ACTIVE,ROLE.NAME, ROLE.ID FROM USER INNER JOIN ROLE ON USER.ROLE_ID=ROLE.ID WHERE CLIENT_ID=?";
    List<User> users = this.getJdbcTemplate().query(sql, new Object[] { client_id }, new UserClientRowMapper());
    return users;
}

private static final class UserClientRowMapper implements RowMapper<User> {
    public User mapRow(ResultSet rs, int rowNum) throws SQLException {
        User user = new User();
        Client client = new Client();
        Role role = new Role();

        user.setID(rs.getInt("ID"));
        user.setUSERNAME(rs.getString("USERNAME"));
        user.setPASSWORD(rs.getString("PASSWORD"));
        user.setACTIVE(rs.getBoolean("ACTIVE"));

        role.setNAME(rs.getString("NAME"));
        role.setID(rs.getInt("ROLE.ID"));

        client.setId(rs.getInt("id"));
        client.setName(rs.getString("name"));

        user.setRole(role);
        user.setClient(client);
        return user;
    }

}

Thanks in advance for your help.

  • 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-14T02:35:13+00:00Added an answer on June 14, 2026 at 2:35 am

    The INNER JOIN keyword returns rows when there is at least one match in both tables. If there are rows in “USER” that do not have matches in “ROLE”, those rows will NOT be listed; of the two users returned by your plain select query, probably one has a null RID column value, or a value that is not in ROLE table.

    Use a LEFT JOIN.

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

Sidebar

Related Questions

I am using SQL Server 2008. I have two tables User ( UserID, Name,
Here's my issue: I have 3 tables, with overlapping information (specifically, the username) in
I have two tables named USER and ROLE with entities as USER and ROLE
I'm seeing basically the same issue described here I have a table that starts
Here's the issue: I have 2 data contexts that I would like to do
Here's the issue: I have a list of App names that I want to
Working with Reporting Services 2008 r2. So here's my issue: We have 5 reports
So I'm not to OOP in PHP. Here is my issue I have a
Having an issue here that I have tried everything I can think of but
I'm have a weird issue here. I have a UITableView using custom UITableViewCells. Everything

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.