miguel_ma Posted January 8, 2011 Share Posted January 8, 2011 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 https://forums.phpfreaks.com/topic/223821-help-please-problem-ordering-filters-on-mysql/ Share on other sites More sharing options...
Pikachu2000 Posted January 8, 2011 Share Posted January 8, 2011 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 https://forums.phpfreaks.com/topic/223821-help-please-problem-ordering-filters-on-mysql/#findComment-1156859 Share on other sites More sharing options...
miguel_ma Posted January 9, 2011 Author Share Posted January 9, 2011 Hello. its working . thank you! Link to comment https://forums.phpfreaks.com/topic/223821-help-please-problem-ordering-filters-on-mysql/#findComment-1156863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.