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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:15:53+00:00 2026-05-23T20:15:53+00:00

table a ————————————————- id name wishlist1 wishlist2 wishlist3 1 john 1 2 3 2

  • 0
table a
-------------------------------------------------
id   name     wishlist1    wishlist2     wishlist3

1    john      1              2            3
2    paul      4              5


table b
--------------------------------------------------
id    goods

1     car
2     aircraft
3     bicycle
4     motorbike
5     ipad


result i want to get
---------------------------------------------------
john    car        aircraft    bicycle
paul    motorbike  ipad

how could i get this result?
(in mysql)

  • 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-23T20:15:54+00:00Added an answer on May 23, 2026 at 8:15 pm

    This outputs up to 3 wishes (with nulls in wish columns when they don’t have a wish)

    select
      name,
      g1.goods as wish1,
      g2.goods as wish2,
      g3.goods as wish3
    from tablea a
    left join tableb g1.id on g1.wishlist1
    left join tableb g2.id on g1.wishlist2
    left join tableb g3.id on g1.wishlist3
    

    This might be better though, and it’s neater, if you don’t mind a comma-delimited list of wishes:

    select
      name,
      group_concat(goods) as wishes
    from tablea a
    left join tableb b on b.id in (a.wishlist1, a.wishlist2, a.wishlist3)
    group by name;
    

    which will output:

    name  |  wishes
    ------|----------------------
    john  |  car,aircraft,bicycle
    paul  |  motorbike,ipad
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

table: user id name ------------- 1 john 2 paul 3 mattew table: nickname id
table_beatles contains the following data in column name . John PAUL george RINGO In
table { id: long name: string } 1235 Fred 1902 Trever 5123 George 6467
table user: |id|name|employee_priority_id|user_priority_id| table priority: |id|name| As you can see, there are two foreign
table 1(ob): name,address table 2(address): dname,addr I need to update ob.address with address.addr when
TABLE tab sl_no name marks status 1 dude 33 y 2 dudz 38 y
Table users: id | firstname | lastname ---+-----------+--------- 1 | John | Smith 2
Table Layout: TABLE ORDER: id localizedInfoId Table OrderLocalizedInfo: id localizedInfoId name With the following
Table Schema Table Name: file_manager_folder Rows: id , parentId , name My query simulates
Table in PostgreSQL database: CREATE TABLE pmss_recordmodel ( id serial NOT NULL, Name character

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.