由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 请问可不可以在sql语句中用序号表示column
相关主题
请问数据表里筛选变量名的写法SQL Server Update Query - non-unique value
SQL aggregate multiple columns in ACCESS求解释
请教SQL这2个query哪个快点,为啥
SQL 2000 create index 問題Oracle Group and Index question
有趣的Join问题,源于SQL和SAS比较。%如何把一个table所有的column都选出来%
每天只工作1小时的日子也挺没劲的。这个sql语句怎么写
请问这个update query有什么问题?sql里怎么做循环?
MS SQL Group By Question一个看似简单的sql语句
相关话题的讨论汇总
话题: select话题: column话题: table话题: yearz话题: yearb
进入Database版参与讨论
1 (共1页)
B****s
发帖数: 5731
1
比如我不知道column name,只是要query第一或第二个column的全部value?
thanks
我用的事mysql
c*****d
发帖数: 6045
2
no

【在 B****s 的大作中提到】
: 比如我不知道column name,只是要query第一或第二个column的全部value?
: thanks
: 我用的事mysql

B****s
发帖数: 5731
3
haoba ,泪奔
B*****g
发帖数: 34098
4
能问一下你要这个干嘛用吗?

【在 B****s 的大作中提到】
: haoba ,泪奔
B****s
发帖数: 5731
5
我这里有些表是对日,月,年等不同时间段的统计,有些字段虽然名字不一样,但是表
的总体结构一样。

【在 B*****g 的大作中提到】
: 能问一下你要这个干嘛用吗?
c*****d
发帖数: 6045
6
比如说每个table都有如下类似字段
tableA: yearA, monA, dateA, otherA
tableB: yearB, monB, dateB, otherB
。。。。
tableZ: yearZ, monZ, dateZ, otherZ
你想写一个sql语句,完成下面的功能,是吗?
select yearA, monA, dateA from tableA;
select yearB, monB, dateB from tableB;
。。。。
select yearZ, monZ, dateZ from tableZ;

【在 B****s 的大作中提到】
: 我这里有些表是对日,月,年等不同时间段的统计,有些字段虽然名字不一样,但是表
: 的总体结构一样。

B*****g
发帖数: 34098
7
似乎他说column的名字不可知,只知道第一列是年,第二列是月,第三列是日.

【在 c*****d 的大作中提到】
: 比如说每个table都有如下类似字段
: tableA: yearA, monA, dateA, otherA
: tableB: yearB, monB, dateB, otherB
: 。。。。
: tableZ: yearZ, monZ, dateZ, otherZ
: 你想写一个sql语句,完成下面的功能,是吗?
: select yearA, monA, dateA from tableA;
: select yearB, monB, dateB from tableB;
: 。。。。
: select yearZ, monZ, dateZ from tableZ;

c*****t
发帖数: 1879
8
select * 的话你取头几个 column 就是了。另外,可以查该 database 的
catalog 里的 table 得到该 table 的 schema 。

【在 B****s 的大作中提到】
: 我这里有些表是对日,月,年等不同时间段的统计,有些字段虽然名字不一样,但是表
: 的总体结构一样。

c*****d
发帖数: 6045
9
en, 比如说每个table都有如下类似字段,但是名字没有规则
tableA: yearAA, AmonA, dateA, otherA
tableB: yearB, monBBBB, dateBB, otherB
。。。。
tableZ: yearZ, monZZ, dateZZZ, otherZ
你想完成下面的功能
select yearAA, AmonA, dateA from tableA;
select yearB, monBBBB, dateBB from tableB;
。。。。
select yearZ, monZZ, dateZZZ from tableZ;
在information_schema.columns中有字段位置,字段名字,表名
用sql语句把他们拼起来

【在 B*****g 的大作中提到】
: 似乎他说column的名字不可知,只知道第一列是年,第二列是月,第三列是日.
c*****d
发帖数: 6045
10
select
concat('select ',GROUP_CONCAT(column_name),' from ',table_name, ';')
from
information_schema.columns
where
table_schema='X'
and
ORDINAL_POSITION <=3
and
table_name LIKE 'Y'
group by
table_name;

【在 c*****d 的大作中提到】
: en, 比如说每个table都有如下类似字段,但是名字没有规则
: tableA: yearAA, AmonA, dateA, otherA
: tableB: yearB, monBBBB, dateBB, otherB
: 。。。。
: tableZ: yearZ, monZZ, dateZZZ, otherZ
: 你想完成下面的功能
: select yearAA, AmonA, dateA from tableA;
: select yearB, monBBBB, dateBB from tableB;
: 。。。。
: select yearZ, monZZ, dateZZZ from tableZ;

B*****g
发帖数: 34098
11
你这个只能搞出sql,不能直接run。
Oracle PLSQL似乎搞不出来前N个(N是parameter),不知道把java搞上能不能行。

【在 c*****d 的大作中提到】
: select
: concat('select ',GROUP_CONCAT(column_name),' from ',table_name, ';')
: from
: information_schema.columns
: where
: table_schema='X'
: and
: ORDINAL_POSITION <=3
: and
: table_name LIKE 'Y'

c*****d
发帖数: 6045
12
这个已经很简便了
直接run搞出的sql就行了

【在 B*****g 的大作中提到】
: 你这个只能搞出sql,不能直接run。
: Oracle PLSQL似乎搞不出来前N个(N是parameter),不知道把java搞上能不能行。

1 (共1页)
进入Database版参与讨论
相关主题
一个看似简单的sql语句有趣的Join问题,源于SQL和SAS比较。
请教: SQL SUM每天只工作1小时的日子也挺没劲的。
新手求教,plsql collection 参数传入问题,非常感谢。请问这个update query有什么问题?
我的DBA在生成ORACLE table的时候需要一个一个column看MS SQL Group By Question
请问数据表里筛选变量名的写法SQL Server Update Query - non-unique value
SQL aggregate multiple columns in ACCESS求解释
请教SQL这2个query哪个快点,为啥
SQL 2000 create index 問題Oracle Group and Index question
相关话题的讨论汇总
话题: select话题: column话题: table话题: yearz话题: yearb