如何从表中获取选定的列名称 [英] How Can I Get Selected Column Names From Table
问题描述
Hello Everyone ..
如何从表中获取选定列名称...这意味着在我的表中我总共有10个,但我想只显示5行,这些都被选中..
对上述情况的查询....
i am使用以下查询来检索所有列,
SELECT column_name FROM information_schema.columns WHERE table_name ='table name'
Hello Everyone..
How can i Get Selected Columns Name From Table.. That Means IN my table I have total 10rows, but i want to display Only 5 rows ,those are Selected..
whats query for that above case....
i am Using the below Query for retrive all Columns ,
"SELECT column_name FROM information_schema.columns WHERE table_name = 'table name'"
推荐答案
您所要做的就是添加WHERE子句以指定一些允许SQL限制它返回的值的条件。例如:
All you have to do is add to your WHERE clause to specify some criteria that allows SQL to limit the values it returns. For example:
SELECT column_name FROM information_schema.columns WHERE table_name = 'MyTable' AND column_name LIKE '&Name'
将仅返回以Name结尾的列:FirstName,LastName和UserName,但不返回NameOfUser ,或密码
will return only the columns that end with "Name": "FirstName", "LastName", and "UserName" but not "NameOfUser", or "Password"
这篇关于如何从表中获取选定的列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!