问题1.  select line_id from station where station_name = A    从1表中得到line_id
   然后用line_id做where条件 再2表中查得我想要的 *   
   SQL语句怎么写?
  我是这样写的
  select * from linelist where id = (select line_id from station where station_name = B
   
  系统说什么子查询结果多于一个之类的问题2.  我想每次再同一个form查得数据后清空datagridview然后再查   在哪里加.clear();  ?问题3.  如果把sql数据库做成便于携带的文件?   写出软件来  还必须的附加数据库才可以正常使用?  有没有什么方法?   小弟新手,见笑,请麻烦详细解答 

解决方案 »

  1.   

    1、
    select * from linelist where id = (select line_id from station where station_name = B 
    -->select * from linelist where id in (select line_id from station where station_name = B )
    2、需要调用你相应控件的clear()
    3、在你的外部程序中做一个备份还原不行?
      

  2.   

    string sql = string.Format("select * from linelist where id in (select line_id from station where station_name like '%{0}%' )", cboSearchStation.Text);
                    dataAdapter = new SqlDataAdapter(sql, DBHelper.con);
                    dataAdapter.Fill(dataset, "station");                 dgvSeachStation.DataSource = dataset.Tables["station"];
    请问在哪里插clear();    
      
      

  3.   

    select * from linelist where id in (select line_id from station where station_name = B )--改為inor
    select * from linelist a where exists(select 1 from station where station_name = B and line_id=a.ID)
      

  4.   

    把“=”改成“in”就行了,主要是要搞明白“=”和“in”的区别。"="是只查询的结果只有一个时,而"in"则是一个或多个时。
      

  5.   

    求问题三  一.二 均以解决 软件都做好了  不至于每次拿给别人用都要人家附加SQL数据库?