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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:29:42+00:00 2026-05-25T10:29:42+00:00

I have a SQL Server database with three tables: Gang, GangMember, and Neighborhood. These

  • 0

I have a SQL Server database with three tables: Gang, GangMember, and Neighborhood. These tables are structured like this:

Neighborhood
------------
ID (non-null)
Name (non-null)

Gang
----
ID (non-null)
Name (non-null)
NeighborhoodID (nullable)

GangMember
----------
ID (non-null)
GangID (non-null)
Name (non-null),
Position (nullable)

I need to get all gangs a gang member belongs to (yes they can belong to multiple). If there is a neighborhood, I need to return that as well. I want my result set to be in the form of: gang.name, neighborhood.name, member.position

So far, I’ve gotten here:

SELECT
 g.[Name],
 '' as 'Neighborhood' /* This what I don't know how to do */
 m.[Position]
FROM
  [Gang] g, 
  [GangMember] m
WHERE
  m.[GangID]=g.[ID]

Because a gang may not have a neighborhood, I’m not sure how to complete this query. Can somebody help me out? Thanks!

  • 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-25T10:29:43+00:00Added an answer on May 25, 2026 at 10:29 am

    Try this:

    SELECT
      g.[Name],
      n.[Name] as 'Neighborhood',
      m.[Position]
    FROM 
      [Gang] g INNER JOIN [GangMember] m ON m.[GangID]=g.[ID]
      LEFT OUTER JOIN [Neighborhood] n ON g.[NeighborhoodID] = n.[ID]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 database. This database has three tables: Person -
If i have SQL Server tables like this: Location ---------- LocationId int PK Field1
We have two tables in a SQL Server 2005 database, A and B.There is
I have a SQL Server Database with several tables. One of them has ID
I have three tables in SQL Server 2008 R2: Country Address and Country_Address Country
I have three websites which uses an abstract database structure with tables like: Items,
I have a Microsoft SQL Server database(tables, relationships and data). But now I want
I have created a simple database in SQL Server Express which consists of three
We have a SQL server database. To manipulate the data non-programmatically, I can use
I have a SQL Server 2008 database. This database has a table called Product,

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.