这条简单的语句怎么优化?
select * from db where A = 'SQL ' union select * from db where B = 'SQL 'union select * from db where C = 'SQL ' union select * from db where D = 'SQL '
请教如何优化呢?
[解决办法]
select * from db where A = 'SQL ' or B = 'SQL ' or C = 'SQL ' or D = 'SQL '
[解决办法]
使用 DISTINCT 消除重复项
DISTINCT 关键字可从 SELECT 语句的结果中除去重复的行。如果没有指定 DISTINCT,那么将返回所有行,包括重复的行。
[解决办法]
select * from db where A = 'SQL '
union select * from db where B = 'SQL '
union select * from db where C = 'SQL '
union select * from db where D = 'SQL '
按优化应试是比:or还好吧!