你的SQL语句有1万多字符啊?。。
解决方案 »
- 请问用C#怎么调用OCI?
- oracle 存储过程的调用问题
- 关于并行服务器中的jdbc编程?如何使用Service_name而不是单独的一个instance名称?
- 如何每天指定时间运行指定得存储过程
- win7下安装了oracle11g,oracle的几个服务程序都代表什么?谁能详细解答下
- 如何查找指定名称的sequence
- 求救:两表间建立外键关联失败!
- 在oracle中在两个整型值之间执行按位逻辑与运算的运算符是什么?
- oracle regexp_replace 字符串值替换问题???
- 1万6千条数据left join 特别慢 求优化sql
- 如何在sql server 中实现oracle 的start with 功能?
- 关于数据库字段匹配问题
=========
我觉得应该有别的方法可以实现
这样的语句,显得沉重一些。。
我有一张suppliers表,一张products表
首先我获得所有的suppliers的id,然后按一定逻辑把这些id排序。然后把这些id连接到product的supplierID,字段,获得所有的product,然后拼在一起显示出来。
例如,suppier的id顺序为 4
1
2
3
生成的product顺序为: SupplierId productId
4 1
4 2
...............
1 100
1 101
...............
2 150
2 152
...............
3 1000
3 1010
我是这样写的 select * from product where supplierid=4
union all
select * from product where supplierid=1
union all
select * from product where supplierid=2
union all
select * from product where supplierid=3
有什么更好的方法?
select * from product where supplierid between 1 and 4;
=========================================================
你不妨这样,把这个排序结果存入临时表your_temp,结构如下:
id supplierid
1 4
2 1
3 2
4 3
然后
select a.* from product a,your_temp b where a.supplierid=b.supplierid order by b.id;
不过确实没有人会写个SQL语句这么长的。。这么长的SQL语句,是没有效率的
也是很难维护的。个人看法而已。。