四个字符串数组的排列组合?
是这样的有两个数组String[]cols={"detailJserial","userName","userConnect","userPhone"};String[]...
是这样的有两个数组
String[] cols = {"detailJserial","userName","userConnect","userPhone"};
String[] value = {order_serial,user_name,user_connect,user_phone};
上面的是字段名,下面的是传过来的变量,一一对应。
要用任意两个组合查询数据
如select * from table where userName=user_name and userPhone=user_phone
麻烦写个算法出来吧。。急用啊。。 展开
String[] cols = {"detailJserial","userName","userConnect","userPhone"};
String[] value = {order_serial,user_name,user_connect,user_phone};
上面的是字段名,下面的是传过来的变量,一一对应。
要用任意两个组合查询数据
如select * from table where userName=user_name and userPhone=user_phone
麻烦写个算法出来吧。。急用啊。。 展开
1个回答
展开全部
using System;
using System.IO;
public class hello
{
static void Main(String[]args){
String[] cols = {"detailJserial","userName","userConnect","userPhone"};
String[] value = {"order_serial","user_name","user_connect","user_phone"};
for(int i=0;i<cols.Length;i++){
for(int j=i+1;j<cols.Length;j++){
String strSQL="SELECT * FROM 表名 where "+cols[i]+"='"+value[i]+"' and "+cols[j]+"='"+value[i]+"'";
Console.WriteLine(strSQL);
}
}
}
}
两个字符串数组遍历就可以了。
using System.IO;
public class hello
{
static void Main(String[]args){
String[] cols = {"detailJserial","userName","userConnect","userPhone"};
String[] value = {"order_serial","user_name","user_connect","user_phone"};
for(int i=0;i<cols.Length;i++){
for(int j=i+1;j<cols.Length;j++){
String strSQL="SELECT * FROM 表名 where "+cols[i]+"='"+value[i]+"' and "+cols[j]+"='"+value[i]+"'";
Console.WriteLine(strSQL);
}
}
}
}
两个字符串数组遍历就可以了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询