Skip to Content Skip to Menu

🕒 Save Time and Effort with CB Editor Assistant: Effortlessly create and refine content in Joomla 3, 4, & 5.
🎁 Limited Offer: Enjoy a 5-day FREE trial and save up to 30% afterward!

[SOLVED] List advanced sorting query syntax

  • coza73
  • coza73
  • OFFLINE
  • Posts: 12
  • Thanks: 1
  • Karma: 0
7 years 10 months ago - 7 years 10 months ago #292267 by coza73
I am trying to setup an advanced list sorting query that lists a few people by a specific field value and the rest by name .

By the info supplied on the configuration page for the advanced sorting you just need to supply a valid ORDER BY statement.

When I put in a ORDER BY statement that has been confirmed to work in mysql I just get the sql error "1064 You have an error in your SQL syntax" when going to list in the front end.

Below is the order by statement I put into the advanced sort configuration.
Code:
ORDER BY CASE WHEN ue.cb_position LIKE "President%" THEN 1 WHEN ue.cb_position LIKE "Vice President%" THEN 2 WHEN ue.cb_position LIKE "Secretary%" THEN 3 WHEN ue.cb_position LIKE "Tresurer%" THEN 4 WHEN ue.cb_position LIKE "Ordinary Committee Member%" THEN 5 ELSE 6 END, u.name

This is the full query that works in mysql
Code:
SELECT DISTINCT ue.*, u.*, '' AS 'NA' FROM j25_users u JOIN j25_user_usergroup_map g ON g.`user_id` = u.`id` JOIN j25_comprofiler ue ON ue.`id` = u.`id` WHERE u.block = 0 AND ue.approved = 1 AND ue.confirmed = 1 AND ue.banned = 0 AND g.group_id IN (2, 3) AND ( `cb_committeemember` = '1' ) ORDER BY CASE WHEN ue.cb_position LIKE "President%" THEN 1 WHEN ue.cb_position LIKE "Vice President%" THEN 2 WHEN ue.cb_position LIKE "Secretary%" THEN 3 WHEN ue.cb_position LIKE "Tresurer%" THEN 4 WHEN ue.cb_position LIKE "Ordinary Committee Member%" THEN 5 ELSE 6 END, u.name

Am I doing it wrong?
Last edit: 7 years 10 months ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
7 years 10 months ago #292285 by krileon
Replied by krileon on topic List advanced sorting query syntax
Don't include ORDER BY as that's added in code resulting in "ORDER BY ORDER BY" causing your SQL syntax error.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: coza73

Please Log in or Create an account to join the conversation.

  • coza73
  • coza73
  • OFFLINE
  • Posts: 12
  • Thanks: 1
  • Karma: 0
7 years 10 months ago #292304 by coza73
Replied by coza73 on topic List advanced sorting query syntax
That did the trick.

Thanks.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum