问题描述
在MySQL下创建表:CREATETABLEtest(idINTNOTNULL,last_nameCHAR(30)NOTNULL,first_nameCHAR(30)NOTNULL,PRIMARYKEY(id),INDEXname(last_name,first_name));CREATETABLEtest(idINTNOTNULL,last_nameCHAR(30)NOTNULL,first_nameCHAR(30)NOTNULL,PRIMARYKEY(id),INDEXname(last_name,first_name));以下语句是否会用到name索引?SELECT*FROMtestWHERElast_name='Widenius';SELECT*FROMtestWHERElast_name='Widenius'ANDfirst_name='Michael';SELECT*FROMtestWHERElast_name='Widenius'AND(first_name='Michael'ORfirst_name='Monty');SELECT*FROMtestWHERElast_name='Widenius'ANDfirst_name>='M'ANDfirst_name<'N';SELECT*FROMtestWHEREfirst_name='Michael';SELECT*FROMtestWHERElast_name='Widenius'ORfirst_name='Michael';
解决方案
解决方案二:
你explain下就知道了
时间: 2025-01-17 19:33:28