SQL LIMIT returns no results where no LIMIT returns results
You are repeating some of the conditions which is not necessary. Try this instead:
SELECT * FROM mm_tfs WHERE (product_slug LIKE '%football%' OR product_description LIKE '%football%') AND schoolid = '8' AND category_id ='21'LIMIT 4
UPDATE:
I have created the following table:
create table mm_tfs2 (schoolid varchar(2), categoryid varchar(2), description varchar(20), slug varchar(20));
And 5 times:
insert into mm_tfs2 values (8, 21, '', 'football');
And finally the query:
select * from mm_tfs2 where (slug like '%football%' and schoolid = 8 and categoryid = 21) or (description like '%football%' and schoolid = 8 and categoryid = 21) limit 4;+----------+------------+-------------+----------+| schoolid | categoryid | description | slug |+----------+------------+-------------+----------+| 8 | 21 | | football || 8 | 21 | | football || 8 | 21 | | football || 8 | 21 | | football |+----------+------------+-------------+----------+4 rows in set (0.00 sec)
So I'm sorry to say that I'm not able to recreate the problem.
I think you could clean it up a little bit, you're getting only rows for one school, and one category ID, so there's no reason that you should have to check for those both times:
SELECT *FROM mm_tfsWHERE schoolid = '8' AND category_id ='21' AND (product_slug LIKE '%football%' OR product_description LIKE '%football%')LIMIT 4;