select a from b where c = d我想把D是一个我随意定的参数
比如
int d
d = f
select a from b where c = d
正确的语句应该怎么写了?

解决方案 »

  1.   

    declare @d int
    set @d = 12
    select a From b where c = @d
      

  2.   

    这个好像是在存储过程里写 我是想在页面?里写如何写?
    比如
                    string sql = "select Profile from MakeFriends where UU=2";
      

  3.   


    SqlCommand cmd = new SqlCommand("select a From b where c = @d");
    执行SqlCommand 命令时的参数化
    cmd.Parameters.Add("@d", SqlDbType.BigInt);
    cmd.Parameters["@d"]= real value
      

  4.   


    PreparedStatement ps = null;String sql = "select a from b where a.name=?";       ps=conn.prepareStatement(sql);
           ps.setString(1,key.trim());
    -----------------
    key.trim()就是你提交过来的参数