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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:46:18+00:00 2026-05-21T16:46:18+00:00

In MS SQL Server I have two tables [Products] and [Product_img] with relationship (ONE

  • 0

In MS SQL Server I have two tables [Products] and [Product_img] with relationship (ONE TO MANY).

SELECT p_id, name FROM dbo.products

| 15 | | name1 |

| 17 | | name2 |

SELECT p_id, path FROM dbo.product_img

| 1.jpg | | 15 |

| 2.jpg | | 15 |

| 3.jpg| | 17 |

| 4.jpg | | 17 |

SELECT dbo.product_img.p_id, dbo.products.name, dbo.product_img.path FROM dbo.product_img INNER JOIN dbo.products ON dbo.product_img.p_id = dbo.products.p_id

| 15 | | name1 | | 1.jpg |

| 15 | | name1 | | 2.jpg |

| 17 | | name2 | | 3.jpg |

| 17 | | name2 | | 4.jpg |

What is the SQL statement that can show the tables like this (with out repeating)?

| 15 | | name1 | | 1.jpg | | 2.jpg |

| 17 | | name2 | | 3.jpg | | 4.jpg |

  • 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-21T16:46:19+00:00Added an answer on May 21, 2026 at 4:46 pm

    USE MAX AND MIN

    SELECT
      dbo.product_img.p_id
    , dbo.products.name
    , MAX(dbo.product_img.path)
    , MIN(dbo.product_img.path) 
    FROM dbo.product_img 
    INNER JOIN dbo.products 
        ON dbo.product_img.p_id = dbo.products.p_id
     GROUP BY dbo.product_img.p_id , dbo.products.name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQL Server 2008 (R2). I have two tables in different databases (with same
I am experiencing an unclear sql server 2008 deadlock. I have two tables: T1:
I have two tables, one called PROJETO (id_projeto, id_tipo_projeto, descr_projeto, versao_projeto) and another called
I have two tables table1 with fields f1 , f2 and table2 with fields
I have a serious(it's getting me crazy) problem with LINQ to SQL . I
I want to know the use of foreign key in SQL Server as I
Is there a way to define a constraint using SQL Server 2005 to not
03-30 13:17] I'm trying to use a t-sql against SQL-Server 2005 with asp 3.0.
A Clarification, if I have a table that has the following fields.... ProductCategoryID, CategoryName,

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.