百科知识

关于将一条SQL语句查出的记录数作为where的查询条件stri

2010-10-17 09:11:22r***
string sql = String.Format("select distinct A.线路 from" + " (select 线路,站点所属 from LineSite where 站点名称 = '{0}') A," + " (select 线路,站点所属 from LineSite where 站点名称 = '{1}') B " + " where A.线路 = B.线路 and A.站点所属 = B.站点所属 and "+ " (" +" select Count(*) as stationCount " + " from lineSite, " + " (select siteID from lineSite where 线路='A.线路' and 站点名称='{0}' and 站点所属='上行线') A, " + " (select siteID from lineSite where 线路='A.线路' and 站点名称='{1}' and 站点所属='上行线')B, " + " (select siteID from lineSite where 线路='A.线路' and 站点名称='{0}' and 站点所属='下行线') C, " + " (select siteID from lineSite where 线路='A.线路' and 站点名称='{1}' and 站点所属='下行线')D " + " where lineSite.线路='A.线路' " + " and " + " (" + " ( A.siteId < B.SiteID " + " AND linesite.siteID between A.siteId and B.SiteID" + " )" + " OR" + " ( A.siteId >= B.SiteID " + " AND " + " linesite.siteID between c.siteId and d.SiteID " + " )" + " )" + ") > 0 ", "师大", "北国商城"); Access数据库 SQL语句如上所示,这样写有问题啊,求高人~ 问题补充: 在Access里不知道为什么执行起来特别慢 所以就在程序里运行了 下面这句话后面的子句有问题,上面的我已经测试过了,没问题。 " where A.线路 = B.线路 and A.站点所属 = B.站点所属 and "+关于将一条SQL语句查出的记录数作为where的查询条件stringsql=String.Format("selectdistinctA.线路from"+"(s?

最佳回答

  • Access库的sql很弱的。。。
    2010-10-18 20:50:26
  • 很赞哦! (99)