我正在尝试为以下查询创建一个视图.
SELECT DISTINCT products.pid AS id, products.pname AS name, products.p_desc AS description, products.p_loc AS location, products.p_uid AS userid, products.isaproduct AS whatisit FROM products UNION SELECT DISTINCT services.s_id AS id, services.s_name AS name, services.s_desc AS description, services.s_uid AS userid, services.s_location AS location, services.isaservice AS whatisit FROM services
但是不能这样做.我正在使用MySql查询浏览器.我得到的错误是:
只能从SELECT命令的活动结果集创建视图
有人可以帮我这个吗?
CREATE VIEW vw_product_services AS SELECT DISTINCT products.pid AS id, products.pname AS name, products.p_desc AS description, products.p_loc AS location, products.p_uid AS userid, products.isaproduct AS whatisit FROM products UNION SELECT DISTINCT services.s_id AS id, services.s_name AS name, services.s_desc AS description, services.s_uid AS userid, services.s_location AS location, services.isaservice AS whatisit FROM services
我试过这个,它有效!感谢大家 :)