Asked  8 Months ago    Answers:  5   Viewed   24 times

Can someone Tell me how to join 3 table with php? Example

SELECT FROM table1, table2,table on INNERJOIN -------------------

let I have 3 table.(question table ,answer table and category table) Here is example form my webpage.

Time remaining 30 minutes(I will get "30 minutes" form Category table)
1. Question (from question table)
2. answer (from answer table)

I don't know how to join 3 table.



it should be like that,

$this->db->join('table2', ' =');
$this->db->join('table3', ' =');
$query = $this->db->get();

as per CodeIgniters active record framework

Wednesday, March 31, 2021
answered 8 Months ago

For me the issue was in the php.ini file. The property mysql.default_socket was pointing to file in a non-existent directory. The property was pointing to /var/mysql/mysql.sock but in OSX, the file was located in /tmp/mysql.sock.

Once I updated the entry in php.ini and restarted the webserver, the issue was resolved.

Wednesday, March 31, 2021
answered 8 Months ago

Don't be afraid to change core files, just alter FCPATH/system/database/drivers/mysqli/mysqli_driver.php

function escape_str($str, $like = FALSE)
    if (is_array($str))
        foreach ($str as $key => $val)
            $str[$key] = $this->escape_str($val, $like);

        return $str;

    if (function_exists('mysqli_real_escape_string') AND is_object($this->conn_id))
        $str = mysqli_real_escape_string($this->conn_id, $str);
        $str = addslashes($str);

    // escape LIKE condition wildcards
    if ($like === TRUE)
        $str = str_replace(array('%', '_'), array('\%', '\_'), $str);

    return $str;

I had the same issue

Better solution -> "stated in github that it will be fixed in CodeIgniter 3.0 the fix already exists in that repository"

Wednesday, March 31, 2021
answered 8 Months ago

Be explicit about which table the column belongs to. This also applies to the SELECT part of the query:

SELECT table1.column AS column1, table2.column AS column2
FROM table1
LEFT JOIN table2
ON table1.column = table2.column

To save you some typing time, use table aliases:

SELECT t1.column AS column1, t2.column AS column2
FROM table1 AS t1
LEFT JOIN table2 AS t2
ON t1.column = t2.column
Wednesday, August 4, 2021
answered 3 Months ago

First lets get a list of values that exist in both tables. If you are using excel 2010 or later then in Sheet 3 A2 put the following formula:


If you are using 2007 or earlier then use this array formula:


Being an array formula, copy and paste into the formula bar then hit Ctrl-Shift-Enter instead of Enter or Tab to leave the edit mode.

Then copy down as many rows as desired. This will create a list of ID'd that are in both lists. This does assume that ID is a number and not text.

Then with that list we use vlookup:


This will then return the value from Sheet 1 that matches.

enter image description here

Wednesday, September 29, 2021
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :