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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:10:01+00:00 2026-05-10T21:10:01+00:00

Alright, so I have a query that looks like this: SELECT `orders`.*, GROUP_CONCAT( CONCAT(

  • 0

Alright, so I have a query that looks like this:

SELECT      `orders`.*,     GROUP_CONCAT(         CONCAT(             `menu_items`.`name`,              ' ($',             FORMAT(`menu_items`.`price`,2),             ')'         ) SEPARATOR '<br>'     ) as `items`,     SUM(`menu_items`.`price`) as `additional`,     `children`.`first_name`,     `children`.`last_name`,     `organizations`.`base_price` FROM      `orders`, `order_items`, `menu_items`, `children`, `organizations` WHERE      `order_items`.`menu_item_id` = `menu_items`.`id` AND      `order_items`.`order_id` = `orders`.`id` AND     `orders`.`added_by` = {$user_id} AND     `orders`.`date` > '{$cutoff}' AND     `children`.`id` = `orders`.`child_id` AND     `organizations`.`id` = `children`.`organization_id` GROUP BY      `orders`.`id` 

I know it’s a monstrosity and that some people will die before not using explicit joins. Ignoring that, however, what I wish to do is to only use the CONCAT inside the GROUP_CONCAT if the menu_items.price is greater than 0, otherwise only return menu_items.name. I have had, however, no success trying to throw an IF in there. I’ve read the manual but all the ways that I’ve tried aren’t working and I’m pretty sure I’m missing something on the whole conditional statements thing.

  • 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. 2026-05-10T21:10:02+00:00Added an answer on May 10, 2026 at 9:10 pm

    Have you tried using something like this?

    CASE WHEN 'menu_items'.'price' = 0 THEN 'menu.items'.'name' ELSE CONCAT (etc) END  

    Replacing the CONCAT statement of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright so I have this C++ image capturing class. I was wondering if I
Alright, currently I have my SWF hitting a php file that will go and
Is it alright to expect that the user using the back end will have
Alright, I have been doing the following (variable names have been changed): FileInputStream fis
Alright. So I have a very large amount of binary data (let's say, 10GB)
Alright...I've given the site a fair search and have read over many posts about
Alright, I'm trying to read a comma delimited file and then put that into
Alright. So I figure it's about time I get into unit testing, since everyone's

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.