【问题标题】:How can I get column number using SQL query如何使用 SQL 查询获取列号
【发布时间】:2021-03-21 16:56:35
【问题描述】:
Select columnnuber
from tablename
where condition

有什么方法可以获取列号。我正在使用 csv jdbc 驱动程序从 cav 文件中检索数据。

【问题讨论】:

  • 请解释一下所说的“列号”是什么意思。
  • 您查看过ResultSet interface 文档吗?没有任何特定于数据库的元数据。

标签: mysql sql jdbc


【解决方案1】:

如果您在执行select * 时想要表格中列的位置——这基本上是创建表格时的位置——那么您可以查看information_schema 表格。

select ordinal_position
from information_schema.columns
where table_name = ? and column_name = ?;

您可能还需要包含table_schema

【讨论】:

    猜你喜欢
    • 2020-10-24
    • 1970-01-01
    • 1970-01-01
    • 2020-08-21
    • 1970-01-01
    • 2015-08-07
    • 2014-10-26
    • 2018-11-01
    • 2010-12-17
    相关资源
    最近更新 更多