SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Self Join
-
May 5, 2003, 18:57 #1
- Join Date
- May 2003
- Location
- nowhere
- Posts
- 2
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Self Join
I use the folowing for a self join in MySQL
SELECT * FROM post_table t1
INNER JOIN post_table t2 ON (t1.post=t2.post)
INNER JOIN post_table t3 ON (t2.post=t3.post)
WHERE t1.index BETWEEN 294 AND 1318
AND t2.index BETWEEN 2210 AND 3379
AND t3.index BETWEEN 30122 AND 30237
This runs very slow and my host doesnt support sub querys. Any ideas on how to make this more efficient
-
May 6, 2003, 05:25 #2
- Join Date
- Jul 2002
- Location
- Toronto, Canada
- Posts
- 39,347
- Mentioned
- 63 Post(s)
- Tagged
- 3 Thread(s)
indexes?
-
May 6, 2003, 09:26 #3
- Join Date
- May 2002
- Location
- Finland
- Posts
- 641
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
First mistake is: SELECT *
You should never ever make an SQL clause that way. Even though you need all fields you'd name them.
If you have heavy join pick only columns you need, that'll make it a lot quicker.
Bookmarks