Question:
I am stuck on mysql IN function using variable.can anybody provide me with source code for
1. HTML form of multiple selection of combo box and
2. extracting result for selected values using IN function
e.g. category ID selected is 1,2,3,4,5,6, sql query would be
$rsresult=mysql_query("select * from tablename where fieldname in ????????? ");
but it doesnt work, Please Help!
Answer:
SELECT * FROM tablename WHERE fieldname IN ('US','UK','GB','CN')
SELECT foo FROM tablename WHERE foo IN (1,2)
but, using IN(2,7,3,5) is returnig results in order 2,7,3,5, How can i get
result in 2,5,3,7 order ?
SELECT * FROM table WHERE id IN(2,7,3,5) ORDER BY FIELD(id,2,5,3,7);
没有评论:
发表评论