rtan_2005 发表于 2007-11-27 10:38

Access里的SQL,不能用UNION吗?

我想用union语句来代替我对text的排序。
  我想让它把数据库中带new标记的先显示,不带new标记的后显示。上次告诉我text字段不能排序。我就想用union来实现,可以吗?

  sql="select * from db where new='' union select * from db where new='none'"

purana 发表于 2007-12-1 10:07

语法错误.

西风独自凉 发表于 2007-12-1 11:40

union select * from db where new='none'

有這樣的語句?

MikeFT 发表于 2007-12-1 11:43

同意楼上二位的说话,union不是这样用的!!!
union好像这样用:
select ...... union select ......

jackyhuang 发表于 2007-12-2 10:05

union的前面和后面都应该是完整的SQL语句,而且字段数应该是相同的,否则好像会出错。

rtan_2005 发表于 2007-12-3 08:38

我可能写得不清楚

sql="select * from db where new='' union select * from db where new='none'"
                                                    ^^这里是两个但引号,就是空

madpbpl 发表于 2008-1-1 17:38

sql="select * from db where new='' union select * from db where new is none"
要用union两个表的结构要一样才可以的。

页: [1]

编程论坛