使用SQL查找表中的列名

问题描述 投票:0回答:2

我目前正在使用 Advantage 数据库。我有一个包含数百个标题的表。如何使用查询查找特定列名?

示例 - 我正在寻找名为“婚姻状况”的列标题,我拥有的唯一详细信息是值“已婚”和“单身”。是否有一个查询可以仅通过使用其值来查找列名称?

sql advantage-database-server
2个回答
0
投票

从描述来看,可能有一个查找参考表(或更多),其中有一些 keyID 和相应的值,并且可能有一列用于查找的用途。然后,您可能会从该表中查询,找到 ID,然后在您的员工(或个人)表中,可能有一些“ID”列,例如 MaritalStatus。这可能就是你缺失的部分。例如

SomeLookupTable
LookupID   UsedFor        UserValue
1          MaritalStatus  Married
2          MaritalStatus  Single
3          MaritalStatus  Divorced
etc...
8          Gender         Male
9          Gender         Female
...
16         SomeOtherUse   Some Value
17         SomeOtherUse   Continue.


Person (or Employee table)
PersonID  GenderID  MaritalStatus
1         8         1
2         9         3

因此,在上面的人员表中,婚姻状况将加入到相应的已婚、单身、离婚、丧偶等值的查找中,因此您永远不会直接在人员表中看到这些单词。


0
投票

从 system.columns 中选择 *,其中 Name=‘Martial’

© www.soinside.com 2019 - 2024. All rights reserved.