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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:38:33+00:00 2026-05-13T10:38:33+00:00

usertable —- id, username grouptable —- id, groupname group_user ——– uid, gid books —-

  • 0
usertable
----
id, username

grouptable
----
id, groupname

group_user
--------
uid, gid

books
----
id, groupname

Input parameters: groupname, username
output: list of books

Is it possible to use 1 sql statement to get list of books when username is inside groupname

Question 2: any good book to recommand to master complex sql statement..

  • 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-13T10:38:34+00:00Added an answer on May 13, 2026 at 10:38 am

    This query gives list of books by user parametar

    SELECT b.id,
    FROM usertable u
         INNER JOIN group_user gu ON gu.uid = u.id
         INNER JOIN grouptable g ON g.id= gu.gid
         INNER JOIN books b ON b.groupname = g.groupname 
    WHERE u.username = @user_name
    

    Also i think if you have the group name you can use

    SELECT b.id,
    FROM grouptable g 
         INNER JOIN books b ON b.groupname = g.groupname 
    WHERE g.groupname = @group_name
    

    Bus having select on both parameters i think is not very good think. This query will get
    list of books for user group name

    SELECT b.id,
        FROM usertable u
             INNER JOIN group_user gu ON gu.uid = u.id
             INNER JOIN grouptable g ON g.id= gu.gid
                  AND g.group_name = @group_name
             INNER JOIN books b ON b.groupname = g.groupname 
        WHERE u.username = @user_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ok so I have this code `$sql = INSERT INTO userTable (username, password, gender,
Consider for instance my following database model. UserTable(Id, Username) TextContentTable(Id, Name, Description, CreatedByUserId, ModifiedByUserId,
Which is faster? SELECT UserName FROM dbo.UserTable WHERE UserID in (1,3,4) SELECT UserName FROM
We have a user table, every user has an unique email and username. We
Like youtube, i have a usertable, a table with objects (videos) and a table
I have a SQL table: CREATE TABLE [UserTable] ( [ID] [int] NULL, [Name] [nvarchar](50)
user_table user_id | username 1 | solomon 2 | muna message table id user_id|
I have these tables: USER TABLE uid | name | role | | 1
I've got a User table with a bitmask that contains the user's roles. The
When designing user table what would be the must have fields from the security/user

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.