I am trying to pass values from dropdown to sql queries. I have two dropdowns Currency and language_code while Currency works fine I have to add ‘%/en/%’ this as value in language_code dropdown for it to work i.e. Pic added below.
Till now I have tried ‘%{{language_code.selectedValue}}%’, %{{language_code.selectedValue}}% and {{language_code.selectedValue}}.
Only this {{language_code.selectedValue}} work with %/en/% this as value from dropdown.
Am I doing something wrong in passing value in ‘LIKE’?
select sum(donation_order.amount) as value from donation_order
inner join accounting_transaction
on accounting_transaction.order_id = donation_order.id
WHERE
accounting_transaction.type = 'donation'
AND donation_order.status= 'paid'
AND accounting_transaction.currency_code = {{Currency.selectedValue}}
AND donation_order.return_url LIKE {{language_code.selectedValue}};
Hello,
What do you want to do by comparing return_url and language_code?
In SQL, the Like keyword is used to search a substring into a string. In your case, the %/en/% will match all the return_url including /en/ string.
A simple example, I have a customer table with a tag column in my database.
If I want to get all the tags including /en/, you can run this following SQL request:
So return url contains language code in database like www.xy.com/en/somepage.
I want to know if it is possible to place language code from dropdown in %/{{ language_code }}/%
SELECT *
FROM customer
where like LIKE '%/{{ language_code }}/%';
Well no, this is my whole query and it returns null while in mysql query should be 4007
select sum(donation_order.amount) as value from donation_order
inner join accounting_transaction
on accounting_transaction.order_id = donation_order.id
WHERE
AND donation_order.status= 'paid'
AND accounting_transaction.currency_code = {{Currency.selectedValue}}
AND donation_order.return_url LIKE '%/' || {{language_code.selectedValue}} || '/%';
I have removed all AND conditions but the results are always the same now
select sum(donation_order.amount) as value from donation_order
inner join accounting_transaction
on accounting_transaction.order_id = donation_order.id
WHERE donation_order.return_url LIKE '%/' || {{language_code.selectedValue}} || '/%';