我想从中返回所有行biometrics,并在存在JOIN的情况下获取更多数据。但是,当前查询仅在用户ID匹配时返回行。
biometrics
我该如何解决这个问题,以便它返回所有生物识别行,以及是否存在来自JOIN的额外数据?
SELECT b.id as id, g.date FROM `biometrics` as b INNER JOIN `users goals` as g ON biometricid = b.id and userid = $user->id
使用左外部联接:
SELECT b.id as id, g.date FROM `biometrics` as b LEFT OUTER JOIN `users goals` as g ON biometricid = b.id and userid = $user->id