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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:13:42+00:00 2026-05-26T14:13:42+00:00

I have three tables. Foo, Attrib, FooAttrib. Where FooAttrib is the bridge between foo

  • 0

I have three tables. Foo, Attrib, FooAttrib. Where FooAttrib is the bridge between foo and attrib. As you can see there are many foo’s and many attribs in the table.

 Foo                 FooAttri                          Attrib
 ------------      -----------------------------     --------------
| id |  Name |    | fooId   |  attribId | value |   | id | Descrip |
|----|-------|    |---------|-----------|-------|   |----|---------|  
|  1 |  Sam  |    |  1      |     1     | red   |   |  1 | Color   |
|  2 |  Bill |    |  1      |     2     | Grape |   |  2 | Flavor  |
|  3 |  Ted  |    |  2      |     1     | Blue  |   |  3 | Weight  |
 ------------     |  3      |     3     |  10   |    --------------
                  |  1      |     3     |   5   |
                  |  2      |     3     |   1   |
                   -----------------------------

I know how to get the following:

fooId   Name     Attrib     Value
1       Sam      Color      red     
1       Sam      Flavor     Grape    
1       Sam      Weight     5
2       Bill     Color      Blue
2       Bill     Weight     1
3       Ted      Weight     10

But what I want to know is; Is it possible to build a select statement so that I get foo and attrib data all returned in one result set that looks like the following?

fooId   Name     Color   Flavor   Weight
1       Sam      red     Grape    5
2       Bill     Blue             1
3       Ted                       10
  • 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-26T14:13:42+00:00Added an answer on May 26, 2026 at 2:13 pm

    You could do it if you know the total possible arguments you want at select time:

    select f.id, f.name, fa_color.value as color, , fa_flavor.value as flavor
    from foo f
    join fooattri fa_color on f.id = fa_color.fooid and fa_color.attribid = 1
    join fooattri fa_flavor on f.id = fa_flavor.fooid and fa_flavor.attribid = 2
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables in the many-to-many format. I.e, table A, B, and AB
I have three tables (definitions below). My question is there can be multiple bar
I have the following tables: table A: FOO (PK) | CLIENT (PK) table B:
Say I have the following tables: TABLE: foo - foo_id (PK) - foo_value Table:
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three tables like that: Articles IdArticle Title Content Tags IdTag TagName ContentTag
I have three tables. This query will write down the right answer (x-lines for
I have three tables in my DB (actually a few more than that) these
I have three tables A: A.pID primary key, A.Name nvarchar(250) B: B.pID primary key,

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.