从SQL数据库中选择特定的行和列 [英] Select specific rows and columns from an SQL database
本文介绍了从SQL数据库中选择特定的行和列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以检索SQL query
中特定行的特定列?
Is it possible to retrieve specific columns of specific rows in an SQL query
?
假设我要从名为my_table
的SQL
表中选择名称为:a,b的行,并使用以下查询文本:
Let's say I'm selecting from my SQL
table, called my_table
, rows whose names are: a, b, using this query text:
"select * from my_table where row_names in ('a', 'b') order by row_names"
如何修改此查询文本以仅选择第2、12、22、32、42列,而不是选择其所有1000列?
How can I modify this query text to select only columns 2,12,22,32,42 rather all its 1000 columns?
推荐答案
将通配符*
替换为要检索的列名.
Replace the wildcard symbol *
with the column names you want to retrieve.
但是请阅读有关SQL标准的文档.在表中几乎不需要1.000列的可能性.
But please read up the documentation on SQL standard. It is very unlikely you need 1.000 columns in a table.
这篇关于从SQL数据库中选择特定的行和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文