Selecting from multiple tables - Returning "MySQL client ran out of memory"

I’m trying to code a search feature for a client on a website that was built years ago, so the way it was coded is a little outdated, but still works just fine.

Basically I’m trying to get the search results to paginate. I tried with multiple queries but I couldn’t get them to paginate properly, so I figured I’d try searching all necessary tables with a single query, which is returning the error “MySQL client ran out of memory”.

I’m not using any joins, which may be the issue.
I’ve tried looking up how to incorporate joins, but the articles that I’ve read seem to be geared toward looking for matching data between tables, whereas I’m trying to search all tables for keywords submitted by the user’s search.

Can someone tell me if I’m using this correctly? And maybe give me some advice?

[php]
$sql = “SELECT
subsections.id,
subsections.name,
subsections.description,
products.id,
products.code,
products.name,
products.description,
pages.id,
pages.title,
pages.content,
blog_entries.id,
blog_entries.name,
blog_entries.content
FROM
subsections,
products,
pages,
blog_entries
WHERE
subsections.name LIKE '%”.mysql_real_escape_string($keywords)."%’ OR
subsections.description LIKE ‘%".mysql_real_escape_string($keywords)."%’ OR
products.code LIKE ‘%".mysql_real_escape_string($keywords)."%’ OR
products.name LIKE ‘%".mysql_real_escape_string($keywords)."%’ OR
products.description LIKE ‘%".mysql_real_escape_string($keywords)."%’ OR
pages.title LIKE ‘%".mysql_real_escape_string($keywords)."%’ OR
pages.content LIKE ‘%".mysql_real_escape_string($keywords)."%’ OR
blog_entries.name LIKE ‘%".mysql_real_escape_string($keywords)."%’ OR
blog_entries.content LIKE ‘%".mysql_real_escape_string($keywords)."%’";
[/php]

Any help would be greatly appreciated.

You have 2 really good responses to the first post you did…

http://www.phphelp.com/forum/general-php-help/long-sql-query-in-php-querying-multiple-tables/msg87037/#msg87037

Sponsor our Newsletter | Privacy Policy | Terms of Service