C#拼接SQL中in条件
一、拼接字符串类型的字段 string sql = @"select distinct ziduan from tablename where ziduan in ('{0}')"; sql=string.Format(sql, string.Join("','", list.ToArray())); 二、拼接数字类型的字段 string sql = @"select distinct ziduan from tablename where ziduan in ({0})"; sql=string.Format(sql, string.Join(",", list.ToArray()));