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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:55:26+00:00 2026-05-23T12:55:26+00:00

I am looking for an access query, but a sql server 2008 could be

  • 0

I am looking for an access query, but a sql server 2008 could be sufficient as I can use a passthrough feature in access.

My data looks like this .

--------------------------------------------------------------
id   nameid   name        score         diff          include 
--------------------------------------------------------------
1     0001     SO          100           0                0
2     0001     SO          100           0                0
3     0001     SO          100           0                0
4     0001     SO          100           0                0
5     0001     SO          100           0                0
6     0001     SO          100           0                0

7     0002     MO          10            0                0
8     0002     MO          18            0                1
9     0002     MO          20            0                0
10    0002     MO          14            0                0
11    0002     MO          100           0                0
11    0002     MO          100           0                0

12    0003     MA          10            0                0
13    0003     MA          18            0                1
14    0003     MA          20            0                0
15    0003     MA          14            0                0
16    0003     MA          100           0                1
17    0003     MA          100           0                0

Now what i want is to go through each row and only select the rows where include = 1. THIS IS EASY however ,I don’t want the entire row.. I want to select the “group”. The group can be identified by the nameid (or name).

So for the above I want the following result:

--------------------------------------------------------------
id   nameid   name        score         diff          include 
--------------------------------------------------------------

7     0002     MO          10            0                0
8     0002     MO          18            0                1
9     0002     MO          20            0                0
10    0002     MO          14            0                0
11    0002     MO          100           0                0
11    0002     MO          100           0                0

12    0003     MA          10            0                0
13    0003     MA          18            0                1
14    0003     MA          20            0                0
15    0003     MA          14            0                0
16    0003     MA          100           0                1
17    0003     MA          100           0                0
  • 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-23T12:55:27+00:00Added an answer on May 23, 2026 at 12:55 pm

    Ask your table for row with include = 1.

    Then join again with the table to have all the rows corresponding to the first query’s nameid :

    SELECT DISTINCT m.*
    FROM myTable m
        INNER JOIN myTable m2
            ON m.nameid = m2.nameid
            AND m2.include = 1
    

    A join query will work better than an ‘in’ query for big amount of datas. You still need an index on the field ‘nameid’, and on ‘include’ could not hurt too.

    An equivalent is with ‘WHERE EXISTS’ :

    SELECT m.*
    FROM myTable m
    WHERE EXISTS
       (
          SELECT * 
          FROM myTable m2
          WHERE m2.include = 1
          AND m2.nameid = m.nameid
       )
    

    You could see the difference here :

    Can an INNER JOIN offer better performance than EXISTS

    And why you have to use a Where exists when you have a filter with a lot of IDs :

    Difference between EXISTS and IN in SQL?

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

Sidebar

Related Questions

I'm looking for an Access 2007 equivalent to SQL Server's COALESCE function. In SQL
I'm looking for a way to create a data access layer that can either
I'm looking to find a way to access the .net query string contained in
I'm looking for access to financial data from Google services. I found this URL
In SQL Server 7.0, I need to find out which users have write access
Looking for code samples to access a memory map file in C#
I'm looking at having certain users access one database and other users accessing another
I'm looking to build a quick link directory access widget. e.g. (option 1) 0-9
I'm looking at building an API and was considering oauth for managing access to
i'm looking to learn about SSO, and heard about Sun Access Manager and openSSO(?)

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.