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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:46:32+00:00 2026-06-02T07:46:32+00:00

I was wondering how I could do this without using group_concat. Since my reviews

  • 0

I was wondering how I could do this without using group_concat. Since my reviews are so long the group_concat is maxing out on them so it does not return all the reviews. The only other way I could think of doing it would be to loop the query. Just so you know there are several products and several reviews for each product. Any ideas?

    $this->db->select("product.id,
        product.name as name,
        group_concat(user.name) as user,
        group_concat(rating.overall) as overall,
        group_concat(rating.description SEPARATOR '|') as review");
    $this->db->join('rating', 'rating.idProduct = alcohol.id', 'LEFT');
    $this->db->join('user', 'user.id = rating.idUser', 'LEFT');
    $query = $this->db->get('product');
    return $query->result();

output as something like this:

[0] => stdClass Object (
        [name] => Product
        [reviews] => Array(
                [0]=> (
                        [user] => "cKendrick "
                        [overall] => "1"
                        [Rating] => "lalalalalala review"
                    )
                [1] = >
                    (...
    )

)
[1] => stdClass Object (..

UPDATE:

"SELECT product.id,
  product.name as name,
  category.permName as category,
  subCategory.permName as subCategory,
  product.permName as permName,
  product.picture as picture,
  user.username as username,
  user.firstName as firstName,
  user.lastName as lastName,
  user.picture as userPicture,
  rating.description as review
FROM (
     SELECT *
     FROM product
     LIMIT ?, 30
) product
LEFT JOIN category
    ON category.id = product.category
LEFT JOIN subCategory
    ON subCategory.id = product.subCategory
LEFT JOIN rating
    ON rating.idAlcohol = product.id
LEFT JOIN user
    ON user.id = rating.idUser
ORDER BY product.lastReview desc"

How would I restrict it by its category?

  • 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-02T07:46:33+00:00Added an answer on June 2, 2026 at 7:46 am

    Which DBAL are you using? In plain old PHP you could do it like this if you really want to use a single query –

    <?php
    
    $db = new PDO('dsn', 'user', 'pass');
    $sql = "SELECT product.id, product.name, rating.overall, rating.description, user.name AS user  
            FROM (
               SELECT *
               FROM product
               LIMIT 30
            ) product   
            LEFT JOIN rating
                ON product.id = rating.productId   
            LEFT JOIN user
                ON user.id = rating.userId";
    
    $stmt = $db->prepare($sql);
    $stmt->execute();
    
    $output = array();
    while ($row = $stmt->fetchObject()) {
        $output[$row->id]['name'] = $row->name;
        $output[$row->id]['reviews'][] = array('user'        => $row->user,
                                               'overall'     => $row->overall,
                                               'description' => $row->description);
    }
    

    UPDATE – I have moved the product table into a subquery to enable limiting the number of products. Note that any filtering on the products should be added to the subquery not the outer select.

    UPDATE – updated query based on update to question. As you want to filter products based on category before limiting the result the joins and criteria need to be added to the subquery –

    SELECT product.id,
        product.name as name,
        product.category,
        product.subCategory,
        product.permName as permName,
        product.picture as picture,
        user.username as username,
        user.firstName as firstName,
        user.lastName as lastName,
        user.picture as userPicture,
        rating.description as review
    FROM (
        SELECT
            p.*,
            category.permName AS category,
            subCategory.permName AS subCategory
        FROM product
        LEFT JOIN category
            ON category.id = product.category
        LEFT JOIN subCategory
            ON subCategory.id = product.subCategory
        WHERE category.permName = ?
        LIMIT ?, 30
    ) product
    LEFT JOIN rating
        ON rating.idAlcohol = product.id
    LEFT JOIN user
        ON user.id = rating.idUser
    ORDER BY product.lastReview desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering how I could handle polymorphism in a for loop without using
I could redo this method using proper Obj-C syntax, but I was wondering how
I had accidentally tried this, which compiles! So I was wondering what could this
I am wondering whether this could be worse parallelizing generation of random numbers. I
I was wondering how I could sort this array, when I use asort right
I was wondering if anyone could explain what this rule is saying: <IfModule mod_rewrite.c>
Wondering if I could get some advice and direction on this following requirement: Need
I was wondering if someone could help me with this. I have defined my
I am asking this as I am wondering if it could be efficient to
I was wondering if anyone could show me how to search this array that

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.