Jump to content

Help please - problem ordering filters on mysql


miguel_ma

Recommended Posts

Hello,

I need help on something:

 

I have a form with 3 selects and a textfield, the textfield is to search the terms inserted on some of the fields of the table and the selects are to filter some fields with fixed falues.

 

I have this query:

 

select * from stone WHERE activo = 's' and (`nome` LIKE '%stones%') OR (`area_extraccao` LIKE '%stones%') OR (`nomes_alternativos` LIKE '%stones%') OR (`info_tecnica` LIKE '%stones%') OR (`descricao` LIKE '%stones%') OR (`analise` LIKE '%stones%') OR (`acabamentos` LIKE '%stones%') OR (`aplicacoes` LIKE '%stones%') OR (`meta_title` LIKE '%stones%') OR (`meta_desc` LIKE '%stones%') OR (`meta_key` LIKE '%stones%') AND cor_clean = 'beige' AND pais_clean = 'portugal' AND tipo_clean = 'granite' order by id desc LIMIT 0, 20

 

 

What i want is to search the keyword only after the 3 filters (cor_clear, pais_ clean and tipo clean) are processed, at the moment they are ignored and i have results from articles that tipo_clean is not granite and the same for others.

 

can anybody help me on this, please.

 

thanks

Give this a try and post the results

SELECT * FROM stone WHERE 
activo = 's' 
AND ( 
(`nome` LIKE '%stones%') OR (`area_extraccao` LIKE '%stones%') OR (`nomes_alternativos` LIKE '%stones%') OR (`info_tecnica` LIKE '%stones%') OR (`descricao` LIKE '%stones%') OR (`analise` LIKE '%stones%') OR (`acabamentos` LIKE '%stones%') OR (`aplicacoes` LIKE '%stones%') OR (`meta_title` LIKE '%stones%') OR (`meta_desc` LIKE '%stones%') OR (`meta_key` LIKE '%stones%') 
)
AND 
(cor_clean = 'beige' AND pais_clean = 'portugal' AND tipo_clean = 'granite') 
ORDER BY id DESC LIMIT 0, 20

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.