mysql 不在或 value=0?
数据库之一称为小部件,它有“id”和“title”。数据库二称为 widget-layouts,它具有“module-id”、“widget-id”、“position”和“weight”。
我想做的是检查 widgets.id 是否存在于 widget-layout.widget-id 中,如果存在,则 widget-layouts.position = 0 。我还想获取不存在的 widgets 的值不存在于小部件布局中。
这是我一直在使用的 mysql 查询。
从小部件、小部件布局中选择 * WHERE (widge-layouts.position = '0' AND widgets.id = widget-layouts.widget-id) 或 widgets.id 不在(选择 * FROM 小部件布局)
通过这个查询,我得到了一个巨大的小部件列表,其中每个小部件都显示多次。
对此有什么想法吗?
Database one is called widgets, it has "id" and "title". Database two is called widget-layouts and it has "module-id", "widget-id", "position", and "weight".
What I am trying to do is check to see if widgets.id exists in widget-layout.widget-id and if it does, then does widget-layouts.position = 0. I also want to get the values of widgets that don't exist in widget-layouts.
Here is the mysql query I have been working with.
SELECT * FROM widgets, widget-layouts
WHERE (widge-layouts.position = '0'
AND widgets.id =
widget-layouts.widget-id) OR
widgets.id NOT IN (SELECT * FROM
widget-layouts)
With this query I am getting a huge list of widgets where each widget is displayed multiple times.
Any ideas about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
应该显示那些存在并且位置 = 0 的内容
应该显示那些仅存在于小部件布局中的内容
should show those that exist and have position = 0
should show those that exist in widget-layouts only