I test with mysql it work, but when I used Oracle, this error appear:
ORA-00979: not a GROUP BY expression
Here is my code:
<?php
$sqlSelect = "SELECT * FROM policy order by policyprogress_id asc";
if (isset($_GET['batch']) && !empty($_GET['batch'])) {
$batch = $_GET['batch'];
$sqlSelect = "SELECT * FROM policy where batch = '".$batch."' group by type order by policyprogress_id asc";
if (isset($_GET['type']) && !empty($_GET['type'])) {
$type = $_GET['type'];
$sqlSelect = "SELECT * FROM policy where batch = '".$batch."' and type = '".$type."' order by policyprogress_id asc";
}
}
SELECT *
is broken withGROUP BY
. If you want an idea of how to fix this problem, then ask a new question. Provide sample data, desired results, and an explanation of the logic you want to implement. I doubt you need three queries for this. One would be more efficient. - Gordon Linoff