按字母顺序排列单词列表并按首字母顺序筛选
问题描述:
我有这个问题,我不知道从哪里开始。
例如,我在我的数据库有这个[这只是示例数据库 ]按字母顺序排列单词列表并按首字母顺序筛选
id word
1 adore
2 and
3 apple
4 asore
5 banana
6 bate
7 beat
8 busy
我怎么能对它进行排序和过滤,所以我只能查看单词,“A”开头的?
id word
1 adore
2 and
3 apple
4 asore
答
select id, word
from your_table
where word like 'a%'
order by id
或
select id, word
from your_table
where substring(word, 1, 1) = 'a'
order by id
答
您可以使用SQL-LIKE语句。
SQL:SELECT DISTINCT word FROM Table WHERE word LIKE 'A%'
这只返回以a开头的单词。
答
这比您想象的要简单得多。您可以使用SQL LIKE operator。
SELECT * FROM table WHERE word LIKE 'a%' ORDER BY word;
+0
非常感谢你 – Butternut 2012-08-10 15:42:24
非常感谢你 – Butternut 2012-08-10 16:04:02