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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:12:02+00:00 2026-06-08T16:12:02+00:00

I have 3 tables in MySQL fruit id| fruit –+——- 1 | apple 2

  • 0

I have 3 tables in MySQL

fruit

id| fruit
--+-------
1 | apple
2 | banana
3 | mango
4 | plum
5 | pear
6 | cherry

list

id| name
--+------------
1 | first list
2 | second list

list_content

id| list_id | fruit_id | active
--+---------+----------+-------
1 |1        |1         |1
2 |1        |2         |1
3 |1        |3         |1
4 |2        |1         |0
5 |2        |6         |1
6 |2        |5         |1
7 |2        |4         |1
8 |2        |3         |1

As a result I need a list ordered by id in descending order with maximum 3 comma separated active elements (if active = 1) ordered by fruit.name in ascending order. Like this

lists  | fruits
-------+------------------
list 2 | cherry, mango, pear
list 1 | apple, banana, mango
  • 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-08T16:12:03+00:00Added an answer on June 8, 2026 at 4:12 pm

    You can use SUBSTRING_INDEX to get only the first 3 fruits.

    SUBSTRING_INDEX(GROUP_CONCAT(IF(active = 1, fruit.name, null) ORDER BY fruit.name ASC),',',3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two MySQL tables: attributes (attributeid, name) productsattributes (productid, attributeid, displayvalue) The required
I have two tables on MySQL, with this structure: Users: id | name Accounts:
I have two tables in MySQL 5.1.38. products +----+------------+-------+------------+ | id | name |
If I have two tables in mysql that have similar columns... TABLEA id name
I have 2 tables in mysql: tableA and tableB tableA: idA tableB: idB, name
I have five mysql tables. shops +----+--------------+--------------+ | id | name | address |
I have two MySQL tables, locations and items: locations `id` `name` `address` `latitude` `longitude`
I have two tables in mysql database groups id|name _______ 1 |red 2 |blue
I have 5 tables in MySQL, but i believe this is a SQL problem
I was thinking that I would have two tables for mysql. One for storing

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.