mysql 子查询帮助
我的 MySql 数据库中有 3 个表:
- 用户;
- 拥有称为数据的日期字段的公司;
- 具有 idUser 和 idCompany 的对象。
我必须检索在公司日期字段中有特定日期的公司,并且满足以下规则: 对象表中不应有 idP=xx 和 idI=(已获取特定起息日期 yy-mm-dd 的公司的 id)的记录
我该如何编写此查询?
I have 3 tables in a MySql Database:
- User;
- Company that has a date field called data;
- Object that has idUser and idCompany.
I have to retrieve Companies that has got a specific date in date field of Company, and that meet the following rule:
There should be no records in Object table that has idP=xx and idI=(an id of a company that has got the specific value date yy-mm-dd)
How can I write this query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
但我不得不说你的列和表命名需要重新完成。这可能更有意义。
您必须为Object.idI和Object.idP创建索引才能使其运行得更快。
But I have to say that your columns and tables naming need to be re-done. It could be a lot more meaningful.
You have to created indexes for Object.idI and Object.idP to make it run quicker.