Hello Abu
I am receiving and error when I use the “All Column Search” and have a calculated column in the MySQL query. It states that it cannot find the calculated column.
“Couldn’t execute query. Unknown column ‘est.quantity * est.administration’ in ‘where clause’…”
$g->select_command = “SELECT
est.id,
est.projectnumberest,
est.tasks,
est.quantity,
est.factor,
est.administration,
t.taskduration,
est.quantity * est.administration as totaladmin
FROM tblestimate est
INNER JOIN tbltask t ON est.tasks = t.task
where est.projectnumberest = ‘$PROJECTNUMBERVAR’
“;
$col = array();
$col[“title”] = “Admin”;
$col[“name”] = “administration”;
$col[“width”] = “100”;
$col[“editable”] = true;
$col[“search”] = true;
$col[“export”] = true;
$col[“align”] = “center”;
//$col[“edittype”] = “lookup”;
//$col[“frozen”] = true;
//$col[“editoptions”] = array(“table”=>”tblpid”, “id”=>”pid”, “label”=>”PID”);
//$col[“show”] = array(“edit”=>false);
$cols[] = $col;
$col = array(); //est.quantity * est.administration as totaladmin,
$col[“title”] = “AdminTotalHrs”;
$col[“name”] = “totaladmin”;
$col[“dbname”] = “est.quantity * est.administration”;
$col[“width”] = “100”;
$col[“editable”] = false;
$col[“search”] = true;
$col[“export”] = true;
$col[“align”] = “center”;
$col[“formatter”] = “number”;
$col[“formatoptions”] = array(“thousandsSeparator” => “,”,
“decimalSeparator” => “.”,
“decimalPlaces” => 2);
//$col[“edittype”] = “lookup”;
//$col[“frozen”] = true;
//$col[“editoptions”] = array(“table”=>”tblpid”, “id”=>”pid”, “label”=>”PID”);
//$col[“show”] = array(“edit”=>false);
$cols[] = $col;
thanks
Tony
Please share complete error message which include incorrect sql query (…)
I sorted it out. I had to place the calculated column contents within brackets
$col = array(); //est.quantity * est.administration as totaladmin,
$col[“title”] = “AdminTotalHrs”;
$col[“name”] = “totaladmin”;
$col[“dbname”] = “(est.quantity * est.administration)”;
$col[“width”] = “100”;
$col[“editable”] = false;
$col[“search”] = true;
$col[“export”] = true;
$col[“align”] = “center”;
$col[“formatter”] = “number”;
$col[“formatoptions”] = array(“thousandsSeparator” => “,”,
“decimalSeparator” => “.”,
“decimalPlaces” => 2);
//$col[“edittype”] = “lookup”;
//$col[“frozen”] = true;
//$col[“editoptions”] = array(“table”=>”tblpid”, “id”=>”pid”, “label”=>”PID”);
//$col[“show”] = array(“edit”=>false);
$cols[] = $col;
thanks
Tony