我有两张 table
Profile Status
profile_id |name | active status_id |profile_id|age
我需要获取配置文件“活跃”为 1 且状态年龄大于 10 的状态
当 profile_id 匹配时,此查询返回
Select * from
status LEFT JOIN ON status.profile_id = profile.profile_id
但是当我放置一个 where 条件时它什么都不显示
Select * from
status LEFT JOIN ON status.profile_id = profile.profile_id
where profile.active= 1 and status.age > 40
左连接是右类型的JOIN吗?
最佳答案
您错过了连接表名称,profile.enabled
应该是 profile.active
试试这个:
Select *
from
status
LEFT JOIN profile ON status.profile_id = profile.profile_id
where
profile.active = 1 and status.age > 40
或
Select *
from
status
LEFT JOIN profile ON status.profile_id = profile.profile_id and status.age > 40
where
profile.active = 1
关于php - mysql 加入 where 条件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24326062/