前面插了个临时表,应该没有什么问题,但是这句SELECT ship_name,a.ship_code, a.buy_ship_benefit_SN, buy_ship_benefit_loan_year_number AS LoanYear FROM HY_buy_ship_benefit a INNER JOIN HY_ship b ON (a.ship_code=b.ship_code) INNER JOIN HY_buy_ship_oil_used d ON (a.ship_code=d.ship_code AND a.buy_ship_benefit_SN=d.buy_ship_benefit_SN ) INNER JOIN HY_buy_ship_line c ON (a.ship_code=c.ship_code AND a.buy_ship_benefit_SN=c.buy_ship_benefit_SN ) INNER JOIN #T e (a.ship_code=e.ship_code AND a.buy_ship_benefit_SN=e.buy_ship_benefit_SN )报错:'a' is not a recognized OPTIMIZER LOCK HINTS option.而
select ship_name,a.ship_code, a.buy_ship_benefit_SN, buy_ship_benefit_loan_year_number AS LoanYear from #T a INNER JOIN HY_ship b ON (a.ship_code=b.ship_code) INNER JOIN HY_buy_ship_benefit c ON (a.ship_code=c.ship_code AND a.buy_ship_benefit_SN=c.buy_ship_benefit_SN) INNER JOIN HY_buy_ship_oil_used d ON (a.ship_code=d.ship_code AND a.buy_ship_benefit_SN=d.buy_ship_benefit_SN ) INNER JOIN HY_buy_ship_line e ON (a.ship_code=e.ship_code AND a.buy_ship_benefit_SN=e.buy_ship_benefit_SN ) ORDER BY a.ship_code ,a.buy_ship_benefit_SN 正确,好像只是前后顺序换换,为什么错啊?想弄懂。
select ship_name,a.ship_code, a.buy_ship_benefit_SN, buy_ship_benefit_loan_year_number AS LoanYear from #T a INNER JOIN HY_ship b ON (a.ship_code=b.ship_code) INNER JOIN HY_buy_ship_benefit c ON (a.ship_code=c.ship_code AND a.buy_ship_benefit_SN=c.buy_ship_benefit_SN) INNER JOIN HY_buy_ship_oil_used d ON (a.ship_code=d.ship_code AND a.buy_ship_benefit_SN=d.buy_ship_benefit_SN ) INNER JOIN HY_buy_ship_line e ON (a.ship_code=e.ship_code AND a.buy_ship_benefit_SN=e.buy_ship_benefit_SN ) ORDER BY a.ship_code ,a.buy_ship_benefit_SN 正确,好像只是前后顺序换换,为什么错啊?想弄懂。
可以到帮助中去找这些相关信息,因为我的Sql server是英文版,大致看了一下,应该与表结构有关
我的英文比较菜^_^
表不是我设计的呀,还有// 回复人: zhysecond(太阳伞) ( ) 信誉:100 2004-09-01 14:45:00 得分: 0
是的,我没办法帮你调试,但我看到你开头写的"select ship_name...",为什么ship_name不指定是哪个table的字段呢?比如"select a.ship_name...",不知道是不是这个问题显然不是,下面一个也是同样的写法,正常,这个不是问题//我想可能与楼主设计的表结构有关系吧(索引,规则等)。
可以到帮助中去找这些相关信息,因为我的Sql server是英文版,大致看了一下,应该与表结构有关
我的英文比较菜^_^显然不是索引得问题,我的表都没有索引,还请大家帮忙
我也是觉得纳闷啊
这是我的SELECT ship_name,a.ship_code, a.buy_ship_benefit_SN, buy_ship_benefit_loan_year_number AS LoanYear FROM HY_buy_ship_benefit a INNER JOIN HY_ship b ON (a.ship_code=b.ship_code) INNER JOIN HY_buy_ship_oil_used d ON (a.ship_code=d.ship_code AND a.buy_ship_benefit_SN=d.buy_ship_benefit_SN ) INNER JOIN HY_buy_ship_line c ON (a.ship_code=c.ship_code AND a.buy_ship_benefit_SN=c.buy_ship_benefit_SN ) INNER JOIN #T e (a.ship_code=e.ship_code AND a.buy_ship_benefit_SN=e.buy_ship_benefit_SN )这是你的SELECT ship_name,a.ship_code, a.buy_ship_benefit_SN, buy_ship_benefit_loan_year_number AS LoanYear FROM HY_buy_ship_benefit a INNER JOIN HY_ship b ON (a.ship_code=b.ship_code) INNER JOIN HY_buy_ship_oil_used d ON (a.ship_code=d.ship_code AND a.buy_ship_benefit_SN=d.buy_ship_benefit_SN ) INNER JOIN HY_buy_ship_line c ON (a.ship_code=c.ship_code AND a.buy_ship_benefit_SN=c.buy_ship_benefit_SN ) INNER JOIN #T e <---- 少了个 ON(a.ship_code=e.ship_code AND a.buy_ship_benefit_SN=e.buy_ship_benefit_SN )你再看看吧,应该是没有少的说:)
SELECT ship_name,a.ship_code, a.buy_ship_benefit_SN, buy_ship_benefit_loan_year_number AS LoanYear
FROM HY_buy_ship_benefit a
INNER JOIN HY_ship b
ON (a.ship_code=b.ship_code)
INNER JOIN HY_buy_ship_oil_used d
ON (a.ship_code=d.ship_code AND a.buy_ship_benefit_SN=d.buy_ship_benefit_SN)
INNER JOIN HY_buy_ship_line c
ON (a.ship_code=c.ship_code AND a.buy_ship_benefit_SN=c.buy_ship_benefit_SN ) INNER JOIN #T e
ON (a.ship_code=e.ship_code AND a.buy_ship_benefit_SN=e.buy_ship_benefit_SN )最后一个 ON 是我加上的。