justjoe300
justjoe300

Reputation: 81

Why wont this left join work?

I am having trouble with this block of code. The error is near LIKE. This is the code...

try {
    $st = $db->query('SELECT', "SELECT a.`fast_cash` as `fast`, a.`urgent_cash` as `urgent`, b.`store_name` as `store` FROM `Locations` a LEFT JOIN `loan_balances` b ON b.`store_name` LIKE '%' + a.`nick` + '%'", 'array'); 
} catch (Exception $e) {
    echo $e->getMessage();
}

Upvotes: 4

Views: 83

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269823

The on clause you are looking for is:

ON b.`store_name` LIKE concat('%', a.`nick`, '%')

No where clause is needed for this query.

Upvotes: 2

Related Questions