我不知道该搜索什么,所以我不知道问题是否已经回答: - )
我有一个返回ID的Oracle函数,我想在SQL select语句中多次使用这个函数。
Excample:
select
custname,
custid,
salesorderid,
getIdFromSalesOrder(salesorderid),
qty,
getPriceFromID(getIdFromSalesOrder(salesorderid)),
getXFromID(getIdFromSalesOrder(salesorderid)),
getYFromID(getIdFromSalesOrder(salesorderid)),
getZFromID(getIdFromSalesOrder(salesorderid))
from
tableX,
tableY
where
.......
有没有办法使用局部变量,所以我不能一次又一次地调用getIdFromSalesOrder
?
Mayby是这样的吗?
id_ number(10,0);
select
custname,
custid,
salesorderid,
getIdFromSalesOrder(salesorderid) into id_,
qty,
getPriceFromID(id_),
getXFromID(id_),
getYFromID(id_),
getZFromID(id_)
from
tableX,
tableY
where
.......
SQL select语句将返回3-4.000行,因此以某种方式变量将需要为pr。行?
祝你好运 安德斯
答案 0 :(得分:1)
您可以使用子查询或CTE:
<?php
$text='data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
$result=preg_replace('/(?<=data:image.{50}).*/', '', $text);
echo $result;
请注意,我在查询中添加了表别名。您应该限定所有表名。另请注意,我添加了正确的,明确的select custname, custid, salesorderid, id_salesorderid, qty,
getPriceFromID(id_salesorderid),
getXFromID(id_salesorderid),
getYFromID(id_salesorderid),
getZFromID(id_salesorderid)
from (select x.*, getIdFromSalesOrder(salesorderid) as id_salesorderid
from tableX x
) x join
tableY y
on . . .;
语法。