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] Query to calculate 2 delimiter fields.

12 years 1 month ago - 12 years 1 month ago #216578 by edmundcheong
I would like to add 2 fields together for example:

cb_number01 + cb_number02

and I have done so using a query:

SELECT TRUNCATE(cb_number01+cb_number02,2) FROM #___comprofiler WHERE id=[user_id]

It did not work but I believe that the challenge here is that cb_number01 and cb_number02 are delimiter field containing some conditions below:

cb_number01 contains the following:

[cb:if cb_age1>=0 and cb_age1<=20]-30[/cb:if]
[cb:if cb_age1>=21 and cb_age1<=50]50[/cb:if]
[cb:if cb_age1>=51]80[/cb:if]

cb_number02 contains the following:

[cb:if cb_age2>=0 and cb_age2<=20]-30[/cb:if]
[cb:if cb_age2>=21 and cb_age2<=50]50[/cb:if]
[cb:if cb_age2>=51]80[/cb:if]

How do i add cb_number01 and cb_number02? Do I a query or I can use another delimiter to add this fields together?

Or the auto action field function would be able to handle this.

Basically, what I am trying to do is to add a few delimiter fields with cb:if condition together..

If I can put in mathematical functions formula in the delimiter fields, it will solve my problem.. so far I am trying the following (below) but it is not working..

[cb_number01]+[cb_number02]

It shows the cb:if value with the "+" in between..
Last edit: 12 years 1 month ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
12 years 1 month ago - 12 years 1 month ago #216608 by krileon
Replied by krileon on topic Re: Query to calculate 2 delimiter fields.
Your table had 1 too many _ (3) as it should be #__ (2). You probably also need to substitution your 2 fields instead of calling from database as a database entry doesn't exist for delimiter fields. Try the below.
Code:
SELECT TRUNCATE( '[cb_number01]' + '[cb_number02]', 2 ) FROM `#__comprofiler` WHERE `id` = '[user_id]'

Ensure debug mode is enabled and maximum error reporting is set within Joomla global configuration during all tests so you can see if a fatal SQL error occurs.


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.
Last edit: 12 years 1 month ago by krileon.

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

12 years 1 month ago #216617 by edmundcheong
Replied by edmundcheong on topic Re: Query to calculate 2 delimiter fields.
I guess as much that delimiters do not exist database entry..

I might have to use the auto action to get these results..

Anyway, can i create another delimiter field and add 2 other delimiter fields?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48709
  • Thanks: 8319
  • Karma: 1447
12 years 1 month ago - 12 years 1 month ago #216628 by krileon
Replied by krileon on topic Re: Query to calculate 2 delimiter fields.

Anyway, can i create another delimiter field and add 2 other delimiter fields?

No, there is no math based substitutions. You can have a 3rd delimiter render the 2 delimiters, but it won't add them together. You should do all your math inside of the SELECT query. Example as follows.
Code:
SELECT ( IF( `cb_age1` >= 0 AND `cb_age1` <= 20, -30, IF( `cb_age1` >= 21 AND `cb_age1` <= 50, 50, IF( `cb_age1` >= 52, 80, 0 ) ) ) + IF( `cb_age2` >= 0 AND `cb_age2` <= 20, -30, IF( `cb_age2` >= 21 AND `cb_age2` <= 50, 50, IF( `cb_age2` >= 52, 80, 0 ) ) ) ) FROM `#__comprofiler` WHERE `id` = '[user_id]'


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.
Last edit: 12 years 1 month ago by krileon.
The following user(s) said Thank You: edmundcheong

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

12 years 1 month ago #216685 by edmundcheong
Replied by edmundcheong on topic Re: Query to calculate 2 delimiter fields.
Perhaps the CB team good work on a field delimiter plugin which could do that.. I think that it will be a powerful tool.. ;) thanks for the support!

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

Moderators: beatnantkrileon
Powered by Kunena Forum