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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:31:51+00:00 2026-05-25T22:31:51+00:00

I have following issue. There are two tables – groups and students and third

  • 0

I have following issue. There are two tables – groups and students and third pivot table group_student.

Query to get students from specific groups (id:1,8) is clear…

   SELECT DISTINCT s.*
   FROM students AS s
   Inner Join group_student AS gs ON gs.student_id = s.id
   Inner Join groups AS g ON g.id = gs.group_id
   WHERE g.id IN ("1","8")

It works. But, how to query, if I want to select just segment of students of group id 1. For example s.name = "john". So the result should be: all students from group id 8 + all students with name "john" from group id 1.

Thanx for posts 🙂

  • 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-25T22:31:52+00:00Added an answer on May 25, 2026 at 10:31 pm

    Try this:

    SELECT DISTINCT s.*
       FROM students AS s
       Inner Join group_student AS gs ON gs.student_id = s.id
       Inner Join groups AS g ON g.id = gs.group_id
       WHERE g.id ="8" or (g.id="1" and s.name = "john")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation in Oracle where I have two tables - Table A
I have the following setup: Tasks, Accounts and Groups tables. Tasks can be assigned
I have the following code that will join two different tables together and provide
I have the following tables with their insert script: DECLARE @A TABLE ( [ID]
I have two tables with the following columns: Table1 { ID NUMBER(15), ROLL_NUM VARCHAR2(9),
I have the following issue using java 1.4 I try to display a very
I have the following issue related to iterating over an associative array of strings
I have the following issue and I would like to know what exactly happens.
I have the following issue with a UTF8 files structured as following: FIELD1§FIELD2§FIELD3§FIELD4 Looking
I'm just starting with Object Oriented PHP and I have the following issue: I

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.