0

I'm using the latest version of codeigniter MVC framework and I'm building a database program that generates reports from our medical database, we have a database that records all bookings made in each of the countries we provide services in, I have an array of all our current active countries populated from a table that looks like so:

Countries array = Array ( [0] => Botswana [1] => Ghana [2] => India [3] => Ireland [4] => Kenya [5] => Middle East [6] => South Africa [7] => Spain [8] => Tanzania [9] => Uganda [10] => UK ) 

From this array I want to pull all the data from each table and join it together to produce one table that I can output in my view, doing so for each individual table is easy and is done via a switch statement that selects the relevant table based on the users $_POST['country'] input on my search form, however I need an option to select all countries that will add each country table (book_<COUNTRY>) to the output array. using SQL it would be a simple union as each bookings table is identicle, ive tried using the JOIN method but im getting no luck, heres the code from my model:

$database = $this->load->database('bookings_dev', TRUE);
$database->select($new_country_cols);
    foreach ($country_tbls_array as $country) {
        $database->from($country);
    }

Any pointers in the right direction? Cheers

Sam
  • 147
  • 3
  • 10
  • Show the tables that you want to join – Yadhu Babu Sep 16 '17 at 05:36
  • @M Khalid Junaid could you link me the original please? @Yadhu Babu I have 12 country tables from book_south_africa to book_UK, I want to Select * from all tables and join the rows so I can show all branches in each country, each branch in each country table has A unique ID (Auto Increment) as the PK and also each store has its own PIN code (EG 123456) Cheers Guys – Sam Sep 18 '17 at 07:50

0 Answers0