发新话题
打印

如何查询并显示同一数据库中两个表的数据

如何查询并显示同一数据库中两个表的数据

各位大侠:
  查询同一数据库中两个表的数据应该是用union all,下面是我使用的语句
sql="select * from (table_1 union all table_2 union all table_3) where name"
  但是不能实现,请各位多指教!

TOP

如何查询并显示同一数据库中两个表的数据

sql="select * from table_1 where name=';Steven'; union all
     select * from table_1 where name=';ChanSir'; union all
     select * from table_1 where name=';Tom';"

TOP

如何查询并显示同一数据库中两个表的数据

非常感谢onlylon大侠,问题解决了,在此多谢了!!
  不过整个语句需要连接起来才能用,如:
   name=request("name")
   sql="select * from table_1 where name like ';%" & name & "%'; union all select * from table_2 where name like ';%" & name & "%'; union all  select * from table_3 where name like ';%" & name & "%';"

TOP

发新话题