What did I do wrong. It echo nothing. The expect output is apple and pear with val good and 0. First, I will get all fruit with price 4 on table_1, then I join table_2, exclude any fruit mark=4, exclude banana, then I join table_3, get the val if factor match 56, so apple match, and pear factor did not match, so return 0. But my code echo nothing, didnot see error, but just echo nothing.
/*
table_1
fruit price
apple 4
apple 5
banana 4
banana 5
pear 4
table_2
fruit mark
apple 5
apple 6
banana 4
banana 7
pear 6
table_3
fruit factor val
apple 56 good
apple 60 OK
banana 89 good
banana 90 good
pear 56 bad
*/
$pri=4;
$sql = $wpdb->get_results( $wpdb->prepare("
SELECT
b.fruit,c.val
FROM table_1 a,
LEFT JOIN table_2 b
ON b.fruit=a.fruit and b.mark != '4'
LEFT JOIN table_3 c
ON c.fruit=a.fruit AND c.factor = '56'
WHERE a.price=%d
",$pri));
print_r(sql);
</div>