2011-10-14 57 views
2
select value from students where coll_Id=1 
    select value from students where coll_Id=2 
    select value from students where coll_Id=3 
    select value from students where coll_Id=4 
    select value from students where coll_Id=5 
    select value from students where coll_Id=6 
    select value from students where coll_Id=7 
    select value from students where coll_Id=8 
    select value from students where coll_Id=9 
    select value from students where coll_Id=10 

如何爲上述語句編寫單個查詢。如何編寫單個查詢以顯示多個輸入的值

+0

從1到10之間coll_Id的學生選擇的價值 –

回答

4
select value from students where coll_Id in (1,2,3,4,5,6,7,8,9,10); 

編輯://看到@ t-clausen.dk

問題的評論。如果你總是在範圍內處理,你可以使用

select value from students where coll_Id between 1 and 10; 

這相當於

select value from students where coll_Id >= 1 and coll_id <= 10; 
+0

kewl bro謝謝 – Ghostman

相關問題