【发布时间】:2018-11-05 09:09:28
【问题描述】:
我编写了一个使用两列的查询,每列都来自不同的表。如何为这些列建立索引,甚至有可能吗?
select countryName, balance
from main.country c
join main.person p on (c.countryId = p.countryId)
where balance = (select MAX(balance)
from main.person p2
join main.country c2 on (c2.countryId = p2.countryId)
where c.countryId = c2.countryId
and p.countryId = p2.countryId)
order by countryName;
【问题讨论】:
-
您的问题似乎与stackoverflow.com/questions/8509026/… 重复。
-
由于某种原因 sql 不允许我加入这些表 create index idx_countryperson on main.country c inner join main.person p on c.countryId=p.countryId(c.countryName, p.余额);
-
不是 sql!该产品名为SQL Server! SQL 是许多关系数据库管理系统使用的语言。 SQL Server 仅在其中。其他包括 Oracle、MySQL、PostgreSQL、MariaDB 等等。
-
好的,我以后就知道了
标签: sql sql-server indexing