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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:54:17+00:00 2026-05-14T03:54:17+00:00

I have read quite a few selcet+update questions in here but cannot understand how

  • 0

I have read quite a few selcet+update questions in here but cannot understand how to do it. So will have to ask from the beginning.

I would like to update a table based on data in another table. Setup is like this:

- TABLE a ( int ; string )
ID     WORD
1      banana
2      orange
3      apple

- TABLE b ( "comma separated" string ; string )
WORDS  TEXTAREA
0      banana                  -> 0,1
0      orange apple apple      -> BEST:0,2,3 ELSE 0,2,3,3
0      banana orange apple     -> 0,1,2,3

Now I would like to for each word in TABLE a append “,a.ID” to b.WORDS like:

SELECT id, word FROM a
(for each) -> UPDATE b SET words = CONCAT(words, ',', a.id) WHERE b.textarea like %a.word%

Or even better: replace the word found in b.textarea with “,a.id” so it is the b.textarea that ends up beeing a comma separeted string of id’s… But I do not know if that is possible.

Tried this but not working. But I think I am getting closer:

UPDATE a, b
SET b.textarea =
replace(b.textarea,a.word,CONCAT(',',a.id))
WHERE a.word IN (b.textarea)
ORDER BY length(a.word) DESC
  • 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-14T03:54:17+00:00Added an answer on May 14, 2026 at 3:54 am

    I had to do “a cleaner double post” of this one to get the answer.

    A solution can be put together based on this manual:
    http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html#function_group-concat

    GROUP_CONCAT will make a comma separated string based on the fileds it shall CONCAT. Perfect. And regarding the preferred solution with no dublicates in the result there is this example in the manual that will filter out dublicates using DISTINCT inside the GROUP_CONCAT:

    mysql> SELECT student_name,
        ->     GROUP_CONCAT(DISTINCT test_score
        ->               ORDER BY test_score DESC SEPARATOR ' ')
        ->     FROM student
        ->     GROUP BY student_name;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is quite a few questions here about Transactions and JUnit. But please have
I know there are quite a few questions concerning access violations, but I have
I have read quite a few posts here for matching nested braces in Ruby
I'm a beginner at Andengine, but I have read quite a lot of tutorials
I have read this question but it's not quite what I was looking for.
I've read around quite a bit but haven't found a definitive answer. I have
I have read few articles about table partioning but still I am bit confused
I have read quite a few posts on SO and around the web of
I understand that this problem is incredibly common and I have read through quite
I've seen a few similar questions but none that quite address this scenario. I

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.