简体   繁体   中英

Multiple select in grocery crud

I have 3 tables in my db "employees", "sign", "subscription", and all of my tables has this same construct.

It is possible to view in one table all my records?

public function index()
{
    $this->grocery_crud->set_table('employees');
    $output=$this->grocery_crud->render();

    $this->grocery_crud->set_table('sign');
    $output2=$this->grocery_crud->render();
    $this->_example_output($output2);
}

This generate 2 tables, but I want to put all records in one table.

Sorry for my english. Thanks for help.

I'm a little confused because above your code you say "view in one table" but below you say "put in one table". I'll assume you want to "view" from the database, not "put" into the database.

If you have access to your SQL, you can get (for viewing) records from all 3 tables in a single SQL statement by using UNION ...

SELECT col1, col2, col3 FROM EMPLOYEES
UNION
SELECT col1, col2, col3 FROM SIGN
UNION
SELECT col1, col2, col3 FROM SUBSCRIPTION

Note that this is 1 SQL statement (I've broken into multiple lines for readability). The database will append the results and return all records to you in one query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM