日期:2014-05-18  浏览次数:20771 次

select case语句查询数据
如果数据库有三个字段English,Simplified,Traditional.根据页面语言string language而查询不同的字段要怎样写那个sql语句获得那个dataset呢

------解决方案--------------------
string sql="SELECT * FROM tb WHERE 1=1";
switch(language)
{
case "English":
sql+=" AND English=.....";
break;
case "Simplified":
sql+=" AND Simplified=.....";
break;

 case "Traditional":
sql+=" AND Traditional=.....";
break;
default:
break;
 }
------解决方案--------------------
探讨
string sql="SELECT * FROM tb WHERE 1=1";
switch(language)
{
case "English":
sql+=" AND English=.....";
break;
case "Simplified":
sql+=" AND Simplified=.....";
break;

case "Trad……