在MySQL中执行关系代数除法SQL查询时出错
我有 3 个表(provider、provider_has_product、product):
我尝试通过此代码进行除法运算:
SELECT DISTINCT `provider_has_product`.`provider_id` FROM `provider_has_product` WHERE NOT EXIST
(SELECT * FROM `product` WHERE NOT EXIST
(SELECT * FROM `provider_has_product` A1 WHERE
A1.`provider_id` = `provider_has_product`.`provider_id` AND
A1.`product_id` = `product`.`id`))
但它不起作用。它显示:错误代码:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在 'SELECT * FROM
productWHERE NOT EXIST 附近使用的正确语法 (SELECT * FROM
provider_has_p' at line 2`
如何在 MySQL 上进行除法并纠正此错误。
I have 3 tables (provider, provider_has_product, product):
(Original here: http://content.screencast.com/users/Maksold/folders/Jing/media/4e6de435-eeac-4602-95e0-2a1b0b4876ad/2012-01-18_0851.png)
I tried division operation by this code:
SELECT DISTINCT `provider_has_product`.`provider_id` FROM `provider_has_product` WHERE NOT EXIST
(SELECT * FROM `product` WHERE NOT EXIST
(SELECT * FROM `provider_has_product` A1 WHERE
A1.`provider_id` = `provider_has_product`.`provider_id` AND
A1.`product_id` = `product`.`id`))
But it dosn't work. It shows: Error Code: 1064
product
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 'SELECT * FROMWHERE NOT EXIST
provider_has_p' at line 2`
(SELECT * FROM
How make division on MySQL and correct this error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查是否有拼写错误。我很确定它是
EXISTS
,而不是EXIST
Check for a typo. I'm pretty sure it's
EXISTS
, notEXIST