简体   繁体   中英

MySQL chain multiple “Match Against”

I'm unable to get this code to work. Any idea how to change that? I tried adding ( ) around the entire condition but that doesn't seem to fix it either.

 SELECT * FROM clients WHERE 
        MATCH(LNAME) AGAINST('aaaa') OR
        MATCH(FNAME) AGAINST('aaaa') OR
        MATCH(MAIL) AGAINST('aaaa') OR
        MATCH(TEL) AGAINST('aaaa')
 SELECT * FROM `clients` WHERE 
        MATCH(`LNAME`) AGAINST('aaaa') OR
        MATCH(`FNAME`) AGAINST('aaaa') OR
        MATCH(`MAIL`) AGAINST('aaaa') OR
        MATCH(`TEL`) AGAINST('aaaa')

OR

SELECT * FROM `clients` WHERE MATCH(`LNAME`,`FNAME`,`MAIL`,`TEL`) AGAINST('aaaa');

$srch->consultar("SELECT * , MATCH ( tecnologia, descriptores, autorTecnologia) AGAINST ('$dato' IN BOOLEAN MODE) AS puntuacion FROM ficha WHERE MATCH (tecnologia, descriptores, autorTecnologia) AGAINST ('$dato' IN BOOLEAN MODE) HAVING puntuacion > 0.5");

pagination use

$sql=$obj->consultas("SELECT * , MATCH ( tecnologia, descriptores) AGAINST ('$param' IN BOOLEAN MODE) AS puntuacion FROM ficha WHERE MATCH (tecnologia, descriptores) AGAINST ('$param' IN BOOLEAN MODE) HAVING puntuacion > 0.2 order by puntuacion desc limit $initReg,$TamPag");

Are you matching all of them against one string? You can make the query much shorter by combining them.

SELECT * FROM `clients` WHERE 
    MATCH(`LNAME`,`FNAME`,`MAIL`,`TEL`) AGAINST('aaaa')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM