select C.color,S.size
from color C,Size S不指定表的连接条件即时笛卡尔积

解决方案 »

  1.   

    ---测试数据---
    if object_id('[Color]') is not null drop table [Color]
    go
    create table [Color]([ID] int,[Color] varchar(4))
    insert [Color]
    select 1,'黑色' union all
    select 2,'白色' union all
    select 3,'黄色'
    if object_id('[Size]') is not null drop table [Size]
    go
    create table [Size]([ID] int,[Size] varchar(4))
    insert [Size]
    select 1,'10码' union all
    select 2,'20码' union all
    select 3,'30码'
     
    ---查询---
    select a.id,a.[Color],b.[size] 
    from [Color] a,[Size] b
    order by a.id---结果---
    id          Color size 
    ----------- ----- ---- 
    1           黑色    10码
    1           黑色    20码
    1           黑色    30码
    2           白色    10码
    2           白色    20码
    2           白色    30码
    3           黄色    10码
    3           黄色    20码
    3           黄色    30码(所影响的行数为 9 行)
      

  2.   

    ---查询---
    select a.[Color],b.[size] 
    from [Color] a,[Size] b
    order by a.id---结果---
    Color size 
    ----- ---- 
    黑色    10码
    黑色    20码
    黑色    30码
    白色    10码
    白色    20码
    白色    30码
    黄色    10码
    黄色    20码
    黄色    30码(所影响的行数为 9 行)