数据库中有两个表,一个是s,有两个字段,分别是title和id,另一表是w,其中有两个字段,wid,和wname,现在在页面上有两个输入框,一个是nme,一个是tle,希望在提交表单之后,查询数据库中title为tle中的字符或者wname为nme中的字符,都是模糊匹配,两个表通过id和wid联系,这条SQL语句怎么写

解决方案 »

  1.   

    try..string sqlstr="select * from s,w where s.id=w.wid and (s.title like '%"+this.tle.Text.Trim()+"%' or w.wname like '%"+this.nme.Text.Trim()+"%')";
      

  2.   

    string sql = " select * from s , w  where s.id=w.wid and s.tle like '%"+tle+"%' and w.name like '%"+nme+"%'";
    要先判断 tle 和 nme 在组合sql 语句,
      

  3.   

    select * from s,w where s.id=w.wid and (s.title like '%"+this.tle.Text.Trim()+"%' or w.wname like '%"+this.nme.Text.Trim()+"%')
      

  4.   

    liujia_0421(SnowLover) 正解:  顶!!!!