Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount! Get 20% off now with code SPOOKY-2024!

Query Field: Update another field

  • cbrace
  • cbrace
  • OFFLINE
  • Posts: 64
  • Thanks: 5
  • Karma: 1
7 years 11 months ago - 7 years 11 months ago #287710 by cbrace
Query Field: Update another field was created by cbrace
Hi all,

I have the following Query Field set up:
Code:
SELECT CASE WHEN cb_2016_pzo_membership_paid = '1' THEN '107,59' ELSE '72,50' END AS locale, btbn0_comprofiler.* FROM btbn0_comprofiler

What I am trying to achieve is the following:

Calculate price based on 'cb_2016_pzo_membership_paid'. If 'cb_2016_pzo_membership_paid ' = 1 then update 'membership_price' to 107,59 if 'cb_2016_pzo_membership_paid ' = 0 then update 'membership_price' to '72,50'

How to do this?
Last edit: 7 years 11 months ago by cbrace.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
7 years 11 months ago #287720 by krileon
Replied by krileon on topic Query Field: Update another field
You don't need a query field for that. A simple IF substitution usage should work fine. Example as follows.

[cb:if cb_2016_pzo_membership_paid="1"]107,59[/cb:if][cb:if cb_2016_pzo_membership_paid!="1"]72,50[/cb:if]

If you still want to use a query then I suggest just doing a simple select with an IF function usage in the select. See the below MYSQL documentation.

dev.mysql.com/doc/refman/5.6/en/control-flow-functions.html#function_if


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.

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

  • cbrace
  • cbrace
  • OFFLINE
  • Posts: 64
  • Thanks: 5
  • Karma: 1
7 years 11 months ago #287735 by cbrace
Replied by cbrace on topic Query Field: Update another field
Thanks for the reply, leaves me with the following question: What kind of field should I use for that then?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48454
  • Thanks: 8280
  • Karma: 1443
7 years 11 months ago #287750 by krileon
Replied by krileon on topic Query Field: Update another field
Depends on where you're doing this as you may not even need a field, but for a substitution only field you'd use a Custom HTML fieldtype.


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.

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

Moderators: beatnantkrileon
Powered by Kunena Forum