Search code examples
mysqlsqlmariadbunionssp

How to use UNION ALL in ssp simple class?


I want to use below SQL query in the ssp2 simple class

 select * from table1 UNION ALL select * from table2

I tried below query ssp::simple class but it does not work.

$table ='';

$joinQuery = ' from table1 UNION ALL table2';

return Ssp::simple($_POST, $this->sql_details, $table, $primaryKey, $columns, 
       $joinQuery, $filterQuery, null, null, null);

Note: I am using Xampp 5.6.24 (MariaDB)


Solution

  • Replace your joinQuery instead of $joinQuery = ' from table1 UNION ALL table2';

        $joinQuery  = ' from (SELECT * from `table1` ';
        $joinQuery .= ' UNION ALL';
        $joinQuery .= ' SELECT * from `table2` ) temp';