陈一发周二珂:selece *from table1,table2与select*from table1 union select*from table2的区别

来源:百度文库 编辑:高考问答 时间:2024/04/28 00:32:57
selece *from table1,table2与select*from table1 union select*from table2的区别

用select*from table1 union select*from table2能过实现两个表的查询但是用selece *from table1,table2时就出现
Microsoft OLE DB Provider for ODBC Drivers (0x80040E21)
ODBC 驱动程序不支持所需的属性。
/haiger/serch.asp, 第 98 行
请各位大侠指点

联合怎么会是一样呢???

table1中有 field1 field2 field3 (others)
table2中有 field1 field2 field3 (others)
select field1,field2,field3 from table1 union select field1,field2,field3
得到的表结构为:field1 field2 field3
select table1.*,talbe2.* from table1,talbe2
得到的表结构是 (field1,field2,field3,(others))table1,(field1,field2,field3,(others))talbe2

实在是懒得写全,如果懂的人应该知道,俺这里的*是他要的字段名,类型一样的字段名,不是sql是的*,嘎嘎!

selece *from table1,table2没有限制条件啊,没有相同项的时候怎么可以用*,后面+上"where table1.* 条件 table2.*"试试!

差别很大。
前者结果是两表的笛卡尔积,后者是两表的并集

union必需两个结果表结构相同,
最终结果没有重复

你语句错在table1.*,table2.*表结构不一样