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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:40:11+00:00 2026-06-14T23:40:11+00:00

hi i have a table in my database . ShopID | ParentID | SELL

  • 0

hi i have a table in my database .

ShopID | ParentID | SELL 

1          0        2,3
2          1        1,2,3
3          1        2,3,4
4          0        5,6
5          4        5,6,7
6          4        6,7,8

i want to add the children SELL values to the parent shop’s SELL values , but don’t want to add duplicate values ,

finally i want to have a table like this

ShopID | ParentID | SELL 

1          0        1,2,3,4
2          1        1,3
3          1        2,4
4          0        5,6,7,8
5          4        5,7
6          4        6,8

is this possible with MySQL , please help . thanks in advance .

  • 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-14T23:40:12+00:00Added an answer on June 14, 2026 at 11:40 pm

    try this:

    SELECT s1.shopid, s1.parentid, IFNULL( s2.sales, s1.SELL ) SELL
    FROM shop s1
    LEFT JOIN (
      SELECT parentid, GROUP_CONCAT( sell ) sales
      FROM shop
      GROUP BY parentid
    )s2 ON s1.ShopId = s2.parentid;
    

    SQL FIDDLE DEMO

    Update Query:

     update shop
        SET SELL=s.SELL 
        from shop join (select s1.shopid,s1.parentid,ifnull(s2.sales,s1.SELL) SELL from shop s1 left join 
        (select parentid,group_concat(sell) sales from shop
        group by parentid) s2
        on s1.ShopId=s2.parentid) s
        on shop.shopid = s.shopid
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have database table but without the index, and I want to add index
I have a database table with some rows that I want to fetch using
I have a database table named Categories . I want to create a form
I have database table with the names of businesses and want to take advantage
I want to read database tables with Attributes. I have Table in database and
I know how to print data from database on html table but i have
i have database table like this +-------+--------------+----------+ | id | ip | date |
My database table have a Timestamp column named as inTime and i am using
i have a database table of website links. i have another table of tags,
I have a table in database that is having some fields one of which

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.