您的位置:首页 > 博客中心 > 数据库 >

informix数据库知识积累

时间:2022-03-14 02:38

一、嵌套查询

informix子查询:嵌套查询
(1)select first 20 * from (select first 40 * from hlrquery_log order by id desc) order by id desc无法执行
上述并不是子查询,而是隐式视图查询。
子查询应该是:
select first 20 * from tablename where col in ( select col1 from tb2 )
informix到了11版才支持隐式视图查询。informix7、8、9、10均不支持这个。
select first 40 * from hlrquery_log where id in ( select first 40 id from hlrquery_log order by id desc);在后面子查询中加了first系统也报不支持这个参数,first关键字不能用在子查询中
(2)上述查询不能执行的解决方法

①将嵌套查询的结果存入临时表,再以临时表做查询(没试验过)

select * from example_table into temp t;
select * from t;

注意,使用这种方法,必须要用创建表的权限。

②使用informix特有的嵌套查询语法

select * from table(multiset(select * from example_table));

这种方法很常用。

二、left join,right join 最后面写的where条件对xxx有效

待续……

热门排行

今日推荐

热门手游