作者:iamlaosong
SQL查询语句用%来做模糊查询,程序中一般要求用户输入部分信息,根据这个信息进行模糊查询。例如用户输入340104,下面这条语句就是查询昨天客户代码为340104开头的所有邮件信息:
select * from tb_evt_mail_clct t where t.clct_date = trunc(sysdate - 1) and t.sender_cust_code like '340104%'
select * from tb_evt_mail_clct t where t.clct_date = trunc(sysdate - 1) and t.sender_cust_code like '%'
有限定值:
select * from tb_evt_mail_clct t where t.clct_date = trunc(sysdate - 1) and nvl(t.sender_cust_code,'0000') like '340104%'
select * from tb_evt_mail_clct t where t.clct_date = trunc(sysdate - 1) and nvl(t.sender_cust_code,'0000') like '%'
select * from tb_evt_mail_clct t where t.clct_date = trunc(sysdate - 1) and nvl(t.sender_cust_code,'0000') like '0000%'
原文地址:http://blog.csdn.net/iamlaosong/article/details/38864707