111,098
社区成员




static string Format(string sqlStr)
{
string result = "";
//移除字符串中的数字
var removeN = Regex.Replace(sqlStr, @"\d", "").Trim();
//移除后结果如果以limit结尾 说明已进行了取数据行
if (removeN.EndsWith("limit"))
{
//返回原始语句
result = sqlStr.Trim();
}
else
{
//返回处理后的语句
result = sqlStr.Trim() + " limit 10000";
}
return result;
}
public string getstr(string str)
{
if (str.LastIndexOf("limit 50)") > -1)
return str + " limit 10000";
else if (str.LastIndexOf("limit 50") != -1)
return str;
else if (str.LastIndexOf("limit 50 100") != -1)
return str;
else if (str.LastIndexOf("limit 100 200") != -1)
return str;
else
return str + " limit 10000";
}
Console.WriteLine(p.getstr("select * from table1"));
Console.WriteLine(p.getstr("select * from table1 where col='val'"));
Console.WriteLine(p.getstr("select * from table2 where col in (select col from table2 limit 50)"));