 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
Advertisement
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
 |
|
 |
07-30-2008, 09:06 AM
|
#1 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 888
Thanks: 168
|
More rows from join clauses
How can I get all the rows from a join clause? instead of 1?
__________________
Wax on, Wax off
|
|
|
|
07-30-2008, 12:39 PM
|
#2 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: In my basement
Posts: 378
Thanks: 45
|
PHP Code:
$query = "SELECT user.name, message.to".
"FROM user, message";
// I wonder if this would work... LIMIT count(*);
__________________
Signatures are nothing but incriminating.
|
|
|
07-30-2008, 12:40 PM
|
#3 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: In my basement
Posts: 378
Thanks: 45
|
PHP Code:
$query = "SELECT user.name, message.to".
"FROM user, message";
// I wonder if this would work... LIMIT count(*);
Try that. I really don't use joins that much. The more queries the better.
__________________
Signatures are nothing but incriminating.
|
|
|
07-30-2008, 01:35 PM
|
#4 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Location: USA
Posts: 194
Thanks: 7
|
By default you should always get more then 1 if there is more then one. As long as you dont have a limit 1 on the end of the query. and aaron isnt that method really slow? (no backing on that statement)
|
|
|
|
07-30-2008, 06:07 PM
|
#5 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: In my basement
Posts: 378
Thanks: 45
|
Count is extremely slow. That was just something I was wondering about (it had no point whatsoever)
The only thing about my query was not using WHERE.
__________________
Signatures are nothing but incriminating.
|
|
|
07-30-2008, 08:31 PM
|
#6 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 888
Thanks: 168
|
Quote:
Originally Posted by CoryMathews
By default you should always get more then 1 if there is more then one. As long as you dont have a limit 1 on the end of the query. and aaron isnt that method really slow? (no backing on that statement)
|
tried it, although I have group by in there for something else.
__________________
Wax on, Wax off
|
|
|
|
07-30-2008, 08:33 PM
|
#7 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: In my basement
Posts: 378
Thanks: 45
|
Then our SQL knowledge fails.
__________________
Signatures are nothing but incriminating.
|
|
|
07-31-2008, 12:50 AM
|
#8 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Location: USA
Posts: 194
Thanks: 7
|
Can you post the Query? or there isnt much else we can do.
|
|
|
|
07-31-2008, 11:28 AM
|
#9 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 888
Thanks: 168
|
sql Code:
SELECT t.tid, t.title AS thread_title, t.created, t.mid, t.fid, f.title AS forum_title, f.DESC AS forum_desc, f.created AS forum_timestamp, fc.title AS fc_title, m.username AS member_username, m.mid AS member_uid, p.created AS post_time, p.msg AS post_msg, m.signature AS member_signature, p.pid, r.rid, COUNT(DISTINCT r.rid) AS rating_count FROM `threads` AS t LEFT JOIN `posts` AS p ON p.tid=t.tid LEFT JOIN `forums` AS f ON f.fid=t.fid LEFT JOIN `forum_categories` AS fc ON f.catid=fc.fcid LEFT JOIN `members` AS m ON m.mid=p.mid LEFT JOIN `member_ratings` AS r ON r.pid=p.pid WHERE t.tid = '".$tid."' AND f.fid = '".$fid."' GROUP BY p.pid ORDER BY p.pid
I only get 1 row from member_ratings
__________________
Wax on, Wax off
|
|
|
|
07-31-2008, 01:59 PM
|
#10 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Location: USA
Posts: 194
Thanks: 7
|
wow thats a hell of a query. Are you sure there even is more then 1 row that should be returned? you have quite a bit of restrictions on that. Also it might be better to break that into more then 1 query, I bet that runs hella slow im gonna guess at least 10 seconds, if the tables have some sort of data in them.
|
|
|
|
07-31-2008, 02:03 PM
|
#11 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 888
Thanks: 168
|
Tried multiple queries, didn't work, and I didn't like the idea in the first place.
By the way, it takes me 1 second. with a cache at least..
With cleared cache, it took 2 seconds. :P
__________________
Wax on, Wax off
|
|
|
|
07-31-2008, 02:09 PM
|
#12 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 888
Thanks: 168
|
Should I reconstruct my code to work with a multiple query? Cause that's what it is, or at least I believe it 100% :P
__________________
Wax on, Wax off
|
|
|
|
07-31-2008, 02:38 PM
|
#13 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 888
Thanks: 168
|
Nevermind, I DID reconstruct the queries and code, and I now have it where theres two queries for the post data and then for the ratings for the post data, inner while loops :p
__________________
Wax on, Wax off
|
|
|
|
07-31-2008, 03:05 PM
|
#14 (permalink)
|
|
The Frequenter
Join Date: Dec 2007
Location: In my basement
Posts: 378
Thanks: 45
|
So is this solved?
Also, is it better to force the browser to cache your page, or cache it on the server, or both? O.o
__________________
Signatures are nothing but incriminating.
|
|
|
08-02-2008, 07:58 AM
|
#15 (permalink)
|
|
The Prestige
Join Date: Dec 2007
Location: On your Hard Drive, hiding like a Virus
Posts: 888
Thanks: 168
|
Quote:
Originally Posted by Aaron
So is this solved?
Also, is it better to force the browser to cache your page, or cache it on the server, or both? O.o
|
cache on server I believe.
__________________
Wax on, Wax off
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|