I have an SQL statement that looks something like:
SELECT * FROM table1 AS bl
INNER JOIN table2 AS vbsa ON bl.id=vbsa.businesslisting_id AND vbsa.section_id ='70'
INNER JOIN table3 AS vbla ON bl.id=vbla.businesslisting_id AND vbla.location_id='1'
WHERE bl.published = '1'
ORDER BY bl.listing_type DESC
For some reason this will not return any rows, however if I remove the ORDER BY clause it does return rows. Any ideas why this would be?
The column listing_type does exist in the DB and contains number values. It is set as varchar type. I thought maybe this was the problem but I tried a different column (ID) and it still did not work.
Thanks
Robert
Found the problem. I have been working on someone else’s code and they did not add indexes to the tables in question.
Therefore when I added the sort by attribute and ran the query it was exceeding the MAX_JOIN_SIZE rows.
I added the indexes and now it works perfect.
Thanks for everyones input.