取出一個表中滿足狀態值=2的幾條數據,再用幾條數據的id查其他表
用thinkphp該怎麼做啊
不是很會聯表查詢
select * from re_deposit where deposit_status = 2
select * from re_client INNER JOIN re_deposit on re_deposit.client_code = re_client.client_code
代言2017-06-07 09:25:28
select * from re_client INNER JOIN re_deposit on re_deposit.client_code = re_client.client_code
where re_deposit.deposit_status = 2
*注意,假如兩個表有字段相同,會出現字段只取其中一個表,所以建議對字添加前綴
//tp3大概是這樣寫
M("re_client")->join("re_deposit on re_deposit.client_code = re_client.client_code","INNER JOIN")->where("re_deposit.deposit_status = 2")->select();