select top 10 db_product.h_id
from (select * from db_product
where h_id not in(
select top 10 db_product.h_id
from db_product,
db_publishs,
db_product_discount
where db_product.pub_id=db_publishs.pub_id 
AND db_product.h_id=db_product_discount.h_id 
AND db_product.h_type='0707'))这是一个分页语句。在查询分析器里执行时为什么提示:"服务器: 消息 170,级别 15,状态 1,行 10
第 10 行: ')' 附近有语法错误。"

解决方案 »

  1.   

    select top 10 db_product.h_id
    from (select * from db_product
    where h_id not in(
    select top 10 db_product.h_id
    from db_product,
    db_publishs,
    db_product_discount
    where db_product.pub_id=db_publishs.pub_id 
    AND db_product.h_id=db_product_discount.h_id 
    AND db_product.h_type='0707')) as t
      

  2.   

    select top 10 a.h_id
    from (select * from db_product b
    where b.h_id not in(
    select top 10 db_product.h_id
    from db_product,
    db_publishs,
    db_product_discount
    where db_product.pub_id=db_publishs.pub_id 
    AND db_product.h_id=db_product_discount.h_id 
    AND db_product.h_type='0707')) a這樣試試?你那樣表裡有表又不使用別明,內表的h_id都無法識別
      

  3.   

    改成这样试试,注意最后那个变量名a:select top 10 db_product.h_id
    from (select * from db_product
    where h_id not in(
    select top 10 db_product.h_id
    from db_product,
    db_publishs,
    db_product_discount
    where db_product.pub_id=db_publishs.pub_id 
    AND db_product.h_id=db_product_discount.h_id 
    AND db_product.h_type='0707'))a
      

  4.   

    不要用not in ,有left join,
    用not in速度太慢,
    如果你数据量不大的话,那无所谓