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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.