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 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 I have an xml document that looks something like this: <xml> <list> <partner>
Alright, let's say I have a table that looks like this: ID | DATE
Alright, I have this program to sparse code in Newick Format, which extracts both
I am working with a legacy database schema that looks like this: product_table table
Alright I have the MYSQL query code setup to pull this information out of
Alright so I have the query (SELECT * FROM jokes WHERE flags < 5
Alright so I have no idea how to even begin doing this But basically
Alright so I have a task, that I have to let the client try
Alright simple question I have integriters like 5 188 4634 And they all need

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.