2016-04-04 51 views
-1

我在SQL編程方面頗爲陌生,但仍然苦於基本。我需要從指定的ID字符串中提取一些特定的行。從特定值的字符串中獲取數據SQL

ID Product City 
1 Apple London 
2 Banana Berlin 
3 Orange Berlin 
4 Orange Paris 
5 Apple Paris 
6 Banana Copenhagen 
7 Banana Copenhagen 
8 Banana London 
9 Apple Paris 
10 Orange London 
11 Apple Berlin 
12 Apple Copenhagen 
13 Apple Paris 

如果我需要選擇ID = 1,2,5,6,10,11,13如何從數據庫中提取這些特定行? 我正在使用SQLite。

在此先感謝。

+0

你嘗試WHERE子句? – Max

回答

2

您應該使用in條款

select * from your_table 
where id in (1,2,5,6,10,11,13) 
+0

如果例如我需要選擇1500個ID並且這些是數據庫中的前1500個條目呢? – Artem

+0

頂部基地上的訂單? – scaisEdge

+0

@Artem。 。 。那麼你應該問另一個問題。這個答案是這個問題的正確答案。 –

相關問題