Forums

MySQL functions in Fields to retrieve in Read Data

emmexx 03 Mar, 2018
I tried to use the IFNULL, IF, and CASE functions in the Fields to retrieve property of a Read Data to no avail. COUNT works, probably other mysql functions work but not the one I need.
Is it possible to use functions other than COUNT?
Is there a particular syntax?

Thank you
maxx
Max_admin 03 Mar, 2018
Hi maxx,

Please provide an example of what you are trying to achieve, SUM and any simple function should work, but complex syntax may not.

Best regards
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
emmexx 03 Mar, 2018

Please provide an example of what you are trying to achieve, SUM and any
simple function should work, but complex syntax may not.


As an example I want the created value if the modifed value of a record is null. So I tried:
IFNULL(modified,created):alias_name
or
IFNULL(Model.modified,Model.created):Model.alias_name
But I got a joomla error:
1582 Incorrect parameter count in the call to native function 'IFNULL'
Similar errors with IF or CASE.

maxx
2D77rus 17 Apr, 2018
Me too!
Looks like comma in function parameters messes things up:
FORMAT(Credappl.amount,2):amount_formatted
DATE_FORMAT(Credappl.date_in,'%d-%m-%Y'):date_alias
- ERROR, but
DATE(Credappl.date_in):date_alias
- OK.

Is there any workaround posible?

Dmitry
2D77rus 19 Apr, 2018
1 Likes
I've got it fixed! Just need to add spaces:
format(Credappl.amount,2):amount_formatted
- ERROR, but
format(Credappl.amount , 2):amount_formatted
works OK. The same with more complex expressions.
healyhatman 27 Apr, 2018
This doesn't appear to work with COALESCE
COALESCE(earnings_rate , template.ordinary_earnings_rate_id):LogicRate
Gives me
​[pre]1064
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '`entry`.`earnings_rate`_id) AS `entry.LogicRate` FROM `#__employee_timesheet_' at line 1[/pre]

I get the same thing from IFNULL

[br]EDIT: NEVERMIND: It works but you have to specify the model for both parameters.
This topic is locked and no more replies can be posted.