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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:20:40+00:00 2026-06-08T22:20:40+00:00

Table_A has entity_id Table_B has a related entity_id with attribute_id = 1 Table_B has

  • 0

Table_A has entity_id

Table_B has a related entity_id with attribute_id = 1

Table_B has a related entity_id with attribute_id = 2

  SELECT Table_B.value
    FROM  Table_A
    LEFT JOIN Table_B
    ON Table_A.entity_id = Table_B.entity_id
    WHERE Table_A.date =  '2012-7-30 00:00:00'
    AND Table_B.attribute_id = 1

I would like to get attribute_id = 1 and attribute_id = 2 into one query.

  • 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-06-08T22:20:41+00:00Added an answer on June 8, 2026 at 10:20 pm

    You can join Table_B a second time and use AS to give it a new name (an alias).

    SELECT Table_B.value, Table_B2.value
    FROM  Table_A
    LEFT JOIN Table_B
    ON Table_A.entity_id = Table_B.entity_id
    LEFT JOIN Table_B AS Table_B2
    ON Table_A.entity_id = Table_B2.entity_id
    WHERE Table_A.date =  '2012-7-30 00:00:00'
    AND Table_B.attribute_id = 1
    AND Table_B2.attribute_id = 2
    

    You can also move the attribute criteria to make it a little clearer what you’re up to:

    SELECT Table_B.value, Table_B2.value
    FROM  Table_A
    LEFT JOIN Table_B
    ON Table_A.entity_id = Table_B.entity_id AND Table_B.attribute_id = 1
    LEFT JOIN Table_B AS Table_B2
    ON Table_A.entity_id = Table_B2.entity_id AND Table_B2.attribute_id = 2
    WHERE Table_A.date =  '2012-7-30 00:00:00'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select values from three tables. Each table has an buyer_entity_id column.
Say a table has several subclass types. How can I see all columns from
My application has an Entity Framework model containing a many-to-many relationship like the following:
I'm designing a blog-like website system from the ground up, based off of PHP
I have two entities // All details has been removed @Entity @Table(name = "A_TABLE_NAME")
Table A has two columns: ID and name I want to input 3 ID
Table A has a computed field called Computed1. It's persisted and not null. Also,
I've a two table: A and B. A has a relation with B as
I have a database table A which stores records, A has a primary key
i have 3 tables A,B and C. table A has column employee_name,id table B

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.