PL/SQL中LIKE函数使用变量 PL/SQL中LIKE函数使用变量
2016-05-28 13:42
639 查看
orcal使用的方法:
like中使用变量方式为:like '%' || 变量名|| '%'
create or replace procedure edrill_report_day as
re_date date;
re_date_str varchar(20);
begin
re_date := trunc(sysdate) - 1;
re_date_str := to_char(re_date, 'yyyymmdd');
·······
select * from table_name where col_1 like '%' || re_date_str || '%'
MYSQL使用'%' +re_date_str +'%'
SELECT shipper.approved,
Dense_rank() OVER (ORDER BY customer.customer_id) AS rank,
Dense_rank() OVER( partition BY shipper.customer_id,shipper.trans_date,shipper.trans_no ORDER BY shipper.trans_no) AS 明细排列, --虚排列方式
customer.customer_id,
customer.short_name,
shipper.trans_date,
part.description,
part.specification,
shipper_line.user_9 AS 件数,shipper_line.line_no,
shipper_line.quantity,
shipper_line.unit_price,
shipper_line.all_amt,
shipper_line.remark,:开始日期 as 开始日期,:结束日期 as 结束日期
FROM shipper,
shipper_line,
part,
customer
WHERE customer.customer_id = shipper.customer_id
AND shipper.trans_no = shipper_line.trans_no
AND shipper_line.part_id = part.part_id
AND shipper.trans_date BETWEEN :开始日期 AND :结束日期
and customer.short_name like '%'||:客户简称||'%'
ORDER BY customer.customer_id,
shipper.trans_no,
shipper_line.line_no
like中使用变量方式为:like '%' || 变量名|| '%'
create or replace procedure edrill_report_day as
re_date date;
re_date_str varchar(20);
begin
re_date := trunc(sysdate) - 1;
re_date_str := to_char(re_date, 'yyyymmdd');
·······
select * from table_name where col_1 like '%' || re_date_str || '%'
MYSQL使用'%' +re_date_str +'%'
SELECT shipper.approved,
Dense_rank() OVER (ORDER BY customer.customer_id) AS rank,
Dense_rank() OVER( partition BY shipper.customer_id,shipper.trans_date,shipper.trans_no ORDER BY shipper.trans_no) AS 明细排列, --虚排列方式
customer.customer_id,
customer.short_name,
shipper.trans_date,
part.description,
part.specification,
shipper_line.user_9 AS 件数,shipper_line.line_no,
shipper_line.quantity,
shipper_line.unit_price,
shipper_line.all_amt,
shipper_line.remark,:开始日期 as 开始日期,:结束日期 as 结束日期
FROM shipper,
shipper_line,
part,
customer
WHERE customer.customer_id = shipper.customer_id
AND shipper.trans_no = shipper_line.trans_no
AND shipper_line.part_id = part.part_id
AND shipper.trans_date BETWEEN :开始日期 AND :结束日期
and customer.short_name like '%'||:客户简称||'%'
ORDER BY customer.customer_id,
shipper.trans_no,
shipper_line.line_no
相关文章推荐
- SQLlite实现增删查改
- mysql表名忽略大小写配置
- SQL十进制和十六进制相互转换
- mysql 解除正在死锁的状态
- MySQL死锁问题实例分析及解决方法(主要是SQL语句可能会产生的问题)
- MySQL: MyISAM和InnoDB的区别
- flask + MongoDB 学习笔记(3):Register & Hashpassword & Login & Logout
- flask + MongoDB 学习笔记 (-1): 个人用记录
- flask + MongoDB 学习笔记: Exceptions, Errors and Solutions
- symfony 使用原始sql
- redis消息发送与订阅
- 深入浅出SQL Server中的死锁
- Oracle 12c创建用户是出现“ORA-65096: invalid common user or role name”的错误 - CalvinR
- Oracle 11g 新特性 - Database Replay (重演) 说明
- VS搭载SQL 常用语句 (1)
- Ehcache Memcache Redis 初步 (一)
- Ehcache Memcache Redis 初步(二)
- mongodb
- MySql5.7环境搭建
- MariaDB允许远程连接