what's wrong with this query

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
bluesman333
Forum Commoner
Posts: 52
Joined: Wed Dec 31, 2003 9:47 am

what's wrong with this query

Post by bluesman333 »

$sql = "SELECT
purchases.purchases_total AS purchases,
goals.misc_goals AS misc,
goals.product_goals AS product,
companies.clientID AS clientID,
companies.company_name AS name,
companies.state AS state
FROM companies, goals, purchases
WHERE companies.clientID = goals.clientID
AND companies.clientID = purchases.clientID
AND goals.goals_year = '$year'
AND purchases.purchases_year = '$year'
ORDER BY state, name
";

I'm not receiving any errors, the script just runs forever and never returns anything. It also forced my computer to crawl, so something was going on in the background. It worked fine until I added a third table. Does MySQL not support more than two tables? I also tried joining the other two tables, but that did not correct the situation.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

you are probaly getting an absurd amount of results.

check your joins as that is probably what is happening.
Post Reply