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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:30:56+00:00 2026-06-17T09:30:56+00:00

I have 2 table, table 2 contains many addresses of shop. Table 2 references

  • 0

I have 2 table, table 2 contains many addresses of shop. Table 2 references with table 1 by Shop_ID
I want to select like that [see image]
please help me!

enter image description here

  • 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-17T09:30:57+00:00Added an answer on June 17, 2026 at 9:30 am

    You could use row_number():

    select shop_id, 
      shop_name,
      shop_address
    from
    (
      select t1.shop_id,
        t1.shop_name,
        t2.shop_address,
        row_number() over(partition by t1.shop_id
                          order by t1.shop_name, t2.shop_address) rn
      from table_1 t1
      inner join table_2 t2
        on t1.shop_id = t2.shop_id
    ) src
    where rn = 1
    

    See a demo on SQL Fiddle

    You can also use an aggregate function:

    select t1.shop_id, 
      t1.shop_name,
      max(t2.shop_address) shop_address
    from Table1 t1
    inner join table2 t2
      on t1.shop_id = t2.shop_id
    group by t1.shop_id, t1.shop_name
    

    See SQL Fiddle with Demo

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

Sidebar

Related Questions

I have a data table that contains a one-to-many self referential relationship: Plant {
I have a table which contains many records. I'm looking for an efficient way
I have a table that contains multiple dropdown menus for a list of profile
I have a table that contains the following columns: ID int, DISTANCE float, EVENT
I have a table that contains all the data about users . Users can
I have a table that contains common entries in two columns. For Example: Column1
I have mysql table called it as R which contains many fields, but I
I have a table which contains the following columns: UniqueID remote_ip_addr platform I want
I have a table like these: Club Table contains: ClubID(IDENTITY), Name, Address Genre table
I have a large database that contains many urls, there are many domains repeating

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.