大神们,帮我看看
我创建一个视图,在视图里用union怎么报错啊!语句为:
CREATE VIEW mainview(MID)
AS
((SELECT ID FROM student)
UNION (SELECT ID FROM teacher));
错误信息为:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'UNION
(SELECT ID FROM teacher))' at line 4
student.ID和teacher.ID 没问题的。这是什么情况啊!我mysql服务器是:mysql-connector-net-6.4.4.msi!
请大侠们帮忙啊!
------解决方案--------------------
试一下这个,另外你的MYSQL版本是多少?
create view mainview
as
select SELECT ID FROM student
union
SELECT ID FROM teacher
------解决方案--------------------mysql> create view v_test as select * from test1 union select * from test1;
Query OK, 0 rows affected (0.05 sec)
------解决方案--------------------CREATE VIEW v_test AS SELECT * FROM aa UNION SELECT * FROM aa;
在5.5.32中没有问题