select #f.ID,#f.title,#f.ty_xq,#f.ty_fydz,#f.c 
from #f , #x #f和#x表中各有1000行
但是,执行了 (1000000 行受影响)每一行都重复显示 1000次
select #f.ID,#f.title,#f.ty_xq,#f.ty_fydz,#f.c 
from #f  
这样执行就没错,这是什么原因( ⊙ o ⊙ )啊! 郁闷死了

解决方案 »

  1.   

    ....
    from #f , #x 知道這是什么意思嗎?
      

  2.   

    select #f.ID,#f.title,#f.ty_xq,#f.ty_fydz,#f.c 
    from #f , #x 这样是笛卡尔集,1000行*1000行=1000000 行(结果)
      

  3.   

    select #f.ID,#f.title,#f.ty_xq,#f.ty_fydz,#f.c 
    from #f , #x 
    得到的是迪卡尔积 相当于cross join
      

  4.   

    select #f.ID,#f.title,#f.ty_xq,#f.ty_fydz,#f.c 
    from #f , #x 
    迪卡尔积
      

  5.   

    你这是交叉连接,产生了迪卡尔积.你带上条件就行了.select #f.ID,#f.title,#f.ty_xq,#f.ty_fydz,#f.c 
    from #f , #x 
    where #f.关键字 = #x.关键字
      

  6.   

    ----------------------------------------------------------------
    -- Author  :fredrickhu(我是小F,向高手学习)
    -- Date    :2009-12-23 16:05:50
    -- Version:
    --      Microsoft SQL Server 2005 - 9.00.4035.00 (Intel X86) 
    -- Nov 24 2008 13:01:59 
    -- Copyright (c) 1988-2005 Microsoft Corporation
    -- Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 1)
    --
    ----------------------------------------------------------------
    --> 测试数据:[a]
    if object_id('[a]') is not null drop table [a]
    go 
    create table [a]([col] int)
    insert [a]
    select 1 union all
    select 2 union all
    select 3 union all
    select 4
    --> 测试数据:[b]
    if object_id('[b]') is not null drop table [b]
    go 
    create table [b]([2] int)
    insert [b]
    select 3 union all
    select 4
    --------------开始查询--------------------------
    select * from a,b
    ----------------结果----------------------------
    /*col         2
    ----------- -----------
    1           3
    2           3
    3           3
    4           3
    1           4
    2           4
    3           4
    4           4(8 行受影响) 
    */--------------开始查询--------------------------
    select * from a cross join b
    ----------------结果----------------------------
    /* col         2
    ----------- -----------
    1           3
    2           3
    3           3
    4           3
    1           4
    2           4
    3           4
    4           4(8 行受影响)
    */
    --------------开始查询--------------------------
    select * from a
    ----------------结果----------------------------
    /* col
    -----------
    1
    2
    3
    4(4 行受影响)
    */
      

  7.   


    select #f.ID,#f.title,#f.ty_xq,#f.ty_fydz,#f.c 
    from #f , #x 
    where #f.c = #x.c and #f.ty_xq like '%芳古园二区%'(1000 行受影响)匹配上 “芳古园二区”只有一行,但重复显示了1000次。
      

  8.   

    楼主需要学习一下基础知识。先读三遍《数据库系统概论(第四版)》 王珊 萨师煊   高等教育出版社 (掌握基础知识和概念) 然后再粗略浏览一遍SQL的官方手册。(方便以后查找,避免类似于考试的时候,给你本政治书也不知道答案在第几章,第几页)