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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:39:42+00:00 2026-05-25T01:39:42+00:00

TABLE 1 +—-+——–+ | id | name | +—-+——–+ | 2 | robin |

  • 0

TABLE 1

+----+--------+
| id | name   |
+----+--------+
|  2 | robin  |
|  3 | jyothi |
|  1 | angel  |
+----+--------+

TABLE 2

+----+---------+--------+
| id | hobbies | ref_id |
+----+---------+--------+
|  1 | walking |      1 |
|  2 | chating |      1 |
|  3 | reading |      2 |
|  4 | walking |      2 |
+----+---------+--------+

I want name & their hobbies who have hobby as ‘walking’ or name is ‘robin’

+----+-----------------+
| name | hobbies       | 
+----+-----------------+
|  1 | walking,chating |      
|  3 | reading,surfing |    
+----+-----------------+

used query:

select name, group_concat(hobbies) as all_hobbies
from test1,test2
where test1.id = test2.ref_id 
and test1.id in (select ref_id
              from test2
              where hobbies = 'walking')
group by name

I don’t want to use subquery or save the entire result as virtual table & the search on all_hobbies though where clause. I want to do accomplish the group_concat columns through where clause or some way around as its increasing my SQL_JOIN_SZIE

I cannt use having here as that has to act as or condition for eg:

Either hobbies is ‘walking’ or name is ‘robin’

  • 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-25T01:39:42+00:00Added an answer on May 25, 2026 at 1:39 am

    I don’t have mysql installed on this machine, but try this query out, I think it should work. You can think of the HAVING clause as a WHERE clause for your GROUP BY.

    select name, group_concat(hobbies) as all_hobbies
    from test1,test2
    where test1.id = test2.ref_id and test1.name = 'robin'
    group by name
    having all_hobbies like '%walking%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Table: UserId, Value, Date. I want to get the UserId, Value for the max(Date)
table data of 2 columns category and subcategory i want to get a collection
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 A tableAID tableBID grade Table B tableBID name description Table A links to
table 1 : id1, name, surname table 2 : id1, id2, value id1 is
Table 1: AccountId, ReferenceId, Name, (lots of other columns) Table 2: AccountId, ReferenceId, (other
table: user id name ------------- 1 john 2 paul 3 mattew table: nickname id
table name:id col1:owner-name col2:book-id1 col3:book-id2 table name:book-name col1:id col2:name Can anyone get me a

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.