how to write a single query for displaying a value for multiple inputs
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开发者_JS百科_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
How to write a single query for the above statement.
select value from students where coll_Id in (1,2,3,4,5,6,7,8,9,10);
EDIT: // see question comment by @t-clausen.dk
If you're always dealing with ranges you could use
select value from students where coll_Id between 1 and 10;
which is equivalent to
select value from students where coll_Id >= 1 and coll_id <= 10;
精彩评论