|
本帖最后由 zjszjs27 于 2012-9-1 16:00 编辑
表AB1如下:
我想根据SRC_BTSID<>CHK_BTSID AND SRC2GNCELLID<>CHK_CELLID这个条件返回数据行
可是我用这个条件得到的是空表,没有任何数据。请问这应该怎么写SQL语句啊?
原始代码如下:
- SELECT AB1.HBSC_NAME, AB1.SRC_BTSID, AB1.SRC2GNCELLID, AB1.NBR_BTSID, AB1.NBR2GNCELLID, AB1.CHK_BTSID, AB1.CHK_CELLID
- FROM
- (
- SELECT A1.HBSC_NAME, A1.SRC_BTSID, A1.SRC2GNCELLID, A1.NBR_BTSID, A1.NBR2GNCELLID, B1.CHK_BTSID, B1.CHK_CELLID
- FROM (SELECT ADD_G2GNCELL.HBSC_NAME, ADD_G2GNCELL.SRC2GNCELLID, ADD_CELLBIND2BTS.BTSID AS SRC_BTSID, ADD_G2GNCELL.NBR2GNCELLID, ADD_CELLBIND2BTS_1.BTSID AS NBR_BTSID FROM (ADD_CELLBIND2BTS INNER JOIN ADD_G2GNCELL ON (ADD_CELLBIND2BTS.HBSC_NAME = ADD_G2GNCELL.HBSC_NAME) AND (ADD_CELLBIND2BTS.CELLID = ADD_G2GNCELL.SRC2GNCELLID)) INNER JOIN ADD_CELLBIND2BTS AS ADD_CELLBIND2BTS_1 ON (ADD_G2GNCELL.HBSC_NAME = ADD_CELLBIND2BTS_1.HBSC_NAME) AND (ADD_G2GNCELL.NBR2GNCELLID = ADD_CELLBIND2BTS_1.CELLID) WHERE ADD_CELLBIND2BTS.BTSID=ADD_CELLBIND2BTS_1.BTSID) AS A1 INNER JOIN (SELECT ADD_CELLBIND2BTS_3.HBSC_NAME, ADD_CELLBIND2BTS_3.BTSID AS CHK_BTSID, ADD_CELLBIND2BTS_3.CELLID AS CHK_CELLID FROM ADD_CELLBIND2BTS AS ADD_CELLBIND2BTS_3) AS B1 ON (A1.HBSC_NAME=B1.HBSC_NAME) AND (A1.[SRC_BTSID]=B1.CHK_BTSID)
- ) AS AB1
- WHERE AB1.SRC_BTSID<>AB1.CHK_BTSID AND AB1.SRC2GNCELLID<>AB1.CHK_CELLID;
复制代码
|
|