我必须用许多like and and语句优化查询,因为由于表中的数据量太大,搜索速度变得非常慢。
我读过一些关于索引和全文索引的书,但不知道如何使用它们。
下面是一个查询示例:
SELECT o.*
FROM (
(op INNER JOIN o on op.idordine=o.idordine)
INNER JOIN f on f.idfornitore=o.idfornitore
)
INNER JOIN u on u.idutente=o.idutente
WHERE f.ragsoc COLLATE UTF8_GENERAL_CI LIKE '%something%'
AND u.idutente COLLATE UTF8_GENERAL_CI LIKE '%somethingelse%'
AND o.codice COLLATE UTF8_GENERAL_CI LIKE '%something%'
AND (o.autorizzazione COLLATE UTF8_GENERAL_CI LIKE '%somethingelse%'
OR o.autorizzazione2 COLLATE UTF8_GENERAL_CI LIKE '%something%'
)
AND (op.codice COLLATE UTF8_GENERAL_CI LIKE '%somethingelse%'
OR op.descrizione COLLATE UTF8_GENERAL_CI LIKE '%$something%'
)
AND op.destinazione COLLATE UTF8_GENERAL_CI LIKE '%$somethingelse%'
AND (o.data BETWEEN '$ed' AND '$ea')
暂无答案!
目前还没有任何答案,快来回答吧!