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

  • Home
  • SEARCH
  • 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 4233830
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:16:13+00:00 2026-05-21T02:16:13+00:00

I have two tables, I’m given USERNAME : User: USERID USERNAME …other fields… AccessRights

  • 0

I have two tables, I’m given USERNAME:

User:
  USERID
  USERNAME
  ...other fields...

AccessRights (Many to One relationship with User.USERID):
  USERID
  GRANT

I want User.* fields, and all of the AccessRights where AccessRights.USERID=User.USERID

I can do this a few ways:

  • Two separate queries, first for User, get the USERID and use that as a parameter in the 2nd query
  • Join the tables, but this duplicates all of the User.* data over many rows
  • Do some funky stored procedure to marshal the results into one field

But I have this gut feeling that I’m not thinking of some better approach, so I thought I’d ask.

  • 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-05-21T02:16:14+00:00Added an answer on May 21, 2026 at 2:16 am

    Depending upon the database, you could also send a script in that outputs multiple resultsets. It also depends upon the language you’re coding in. But in Java, you can retrieve multiple resultsets from a query if you use Statement.execute (versus executeQuery).

    This way, you can query from the User table first, then populate the user you’re looking for into a local variable, then use that variable to query the AccessRights table.

    In all likelihood, unless you’re talking about a ton of rows in AccessRights or a ton of columns in User, it’s far simpler, and more efficient, to do a join. Just try to get only the fields from User that you need. The extra bytes of data moving across the wire is likely less overhead than multiple hits to the database to query each table individually (unless you use the approach above, which is one hit, but it’s probably overkill for most situations because it is a bit complex).

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

Sidebar

Related Questions

I have two tables: User and Event in a many-to-many relationship. For this I
I have two tables: one table (okay, it's a view), vComputer, lists many computers
Have two sets of data (two tables) for patient records, one 1999-2003, the other
I have two tables, one linked to the Primary Key of the other. At
I have two tables (renamed/refactored for illustrative purposes) with a Many-To-Many relationship in an
Have two tables with a linking table between them. USERS +-------+---------+ | userID| Username|
I have two tables. One contains members and the other members dogs . The
I have two tables, one for routes and one for airports. Routes contains just
I have two tables inside a database. One stores unique userNames and a unique
I have two tables with this structure: Table one: ID Description Table two: ID

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.