如何优化几个“WHERE (Select ....) = value”来自同一张桌子
对我来说很难起一个主题名称。但我可以举一个例子:
WHERE (SELECT [ID_Line] FROM [Event] WHERE [Event].[Name] = [A].[Col]) = 2
AND (SELECT [DataType] FROM [Event] WHERE [Event].[Name] = [A].[Col]) = 2
在这里,当我确实需要类似的东西时,我正在处理 2 个查询:
WHERE (SELECT [ID_Line],[DataType] FROM [Event] WHERE [Event].[Name] = [A].[Col]) = 2,2
但是 SQL 不适用于元组,所以我必须在这里进行 Inner Join 吗?
It's hard to compose a topic name for me. But I can show an example :
WHERE (SELECT [ID_Line] FROM [Event] WHERE [Event].[Name] = [A].[Col]) = 2
AND (SELECT [DataType] FROM [Event] WHERE [Event].[Name] = [A].[Col]) = 2
Here I'm processing 2 queries when I really need something like that :
WHERE (SELECT [ID_Line],[DataType] FROM [Event] WHERE [Event].[Name] = [A].[Col]) = 2,2
but SQL doesn't work with tuples, so must I make Inner Join here ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试这样的操作:
如果您提供有关完整查询和数据库结构的更多信息,则可以给出更准确的答案。这可能不是最好的解决方案。
you can try something like this :
If you provide more information about the complete query and your database structure, a more precise answer could be given. It is possible that this isn't the best solution.
您可以尝试使用熔化操作符来熔化场。在 ORACLE PL/SQL 中,您使用 || (双管),例如。
You can try to melt the fields using a melting operator. In ORACLE PL/SQL you use || (double pipe), for example.