A表
a_id name ........
1 张三
2 李四
3 王五
4 赵六B表:
b_id a_id total qianfei
1 1 100 100
2 3 200 0<form method="post" name="frm" id="frm" action="?act=list">
<input name="qianfei" id="qianfei" value="1" type="checkbox" {if $qianfei gt '0'}checked="checked"{/if} /> 欠费
<input name="sou" type="button" class="ann10" value="" onclick="s_xueyuan()" />
</form>
在B表中,张三欠费100,而李四和赵六根本没有交费记录,勾选上面的欠费(qianfei字段)提交后除了搜索出张三,还怎么搜索出李四和赵六????
a_id name ........
1 张三
2 李四
3 王五
4 赵六B表:
b_id a_id total qianfei
1 1 100 100
2 3 200 0<form method="post" name="frm" id="frm" action="?act=list">
<input name="qianfei" id="qianfei" value="1" type="checkbox" {if $qianfei gt '0'}checked="checked"{/if} /> 欠费
<input name="sou" type="button" class="ann10" value="" onclick="s_xueyuan()" />
</form>
在B表中,张三欠费100,而李四和赵六根本没有交费记录,勾选上面的欠费(qianfei字段)提交后除了搜索出张三,还怎么搜索出李四和赵六????
樓主應該是要找出未交費或有欠費的用戶select t1.name from a as t1 left join b as t2 on t1.a_id=t2.a_id where qianfei is null or qianfei>0;可以這樣寫,先left join,然後找出qianfei>0 或 qianfei為null的記錄即可。