- Bonus
- May 12, 2007
-

im gay
|
My SQL is a little rusty but here's a shot at it
code:SELECT recipient.name, author.name, messages.message
FROM users AS recipient
INNER JOIN messages ON messages.recipient = recipient.id
INNER JOIN users AS author ON author.id = messages.author
WHERE recipient.id = [the id of the guy who is looking at his messages]
|
|
#
¿
Nov 21, 2007 10:42
|
|
- Bonus
- May 12, 2007
-

im gay
|
I don't know about the queries not running, it's best to just see what the SQL error messages tell you and act on that. But as for the slow queries, have you created indices everywhere where they used to be? Because if, say, your foreign keys aren't indexed the DBMS will be doing full table scans on joins.
|
|
#
¿
Nov 23, 2007 09:56
|
|
- Bonus
- May 12, 2007
-

im gay
|
You can see how efficient your query is. How much records needed to be traversed to get the results of the query. For instance, you almost never want to do full table scans. It's good to check your queries with explain to see if full table scans are happening at certain queries so you can introduce indices or reform the queries.
|
|
#
¿
Dec 4, 2007 19:10
|
|