要同时查询两张表的内容,两张表的结构一样,记录可能有重复的,其中TableA(记录较多), TableB(记录较少),其中 TableB 中的表的记录可能在TableA中存在,查询的时候尽量不要重复?例如:TableA
Title,Album,ArtistTableB
Title,Album,Artist------------------------我的查询过程如下:
select p.title,p.album,p.artist from (select distinct title,album,artist from TableB
union
select distinct title,album,artist from TableA as t where t.title not in (select title from TalbeB group by title)
) as pwhere p.title like '%要查询的内容%'-----------------------怎么能提高这个查询的性能?给TableA的Title字段建索引有效果吗?