join()

Combines data from multiple tables using SQL JOIN logic. You can join any table using INNER, LEFT, RIGHT, or FULL (where supported).

Signature:

public function join(string $joinTable, string $joinCondition, string $joinType = 'LEFT'): self

Basic Example

// Get all orders with user info
$db->join('test_users u', 'u.id = o.user_id', 'LEFT');
$db->get('test_orders o', null, 'o.*, u.email');

Supported JOIN Types

INNER JOIN (default)

Returns only rows with matching values in both tables.

LEFT JOIN

Returns all rows from the left table, plus matched rows from the right.

RIGHT JOIN

Returns all rows from the right table, plus matched rows from the left.

FULL JOIN

Returns all rows when there is a match in either table (not supported in MySQL).

See Also