quick question on left join query
Moderator: General Moderators
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
quick question on left join query
"SELECT scrusersonline.*, COUNT(scrusersonline.usersonlineid) AS idcount FROM scrusersonline LEFT JOIN topic ON topic.topic_id=scrusersonline.topic_id WHERE topic.subject_id='$type' scrusersonline.usersonlineusrip!='1' AND scrusersonline.id!='0' GROUP BY scrusersonline.topic_id ORDER BY scrusersonline.idcount DESC"
Anyone know why this does not work? without the join it works fine, and I have joined other queries without a problem, the only difference is that I need a count number in this one. If anyone can help me out or give me a tip, I would really appreciate it.
Anyone know why this does not work? without the join it works fine, and I have joined other queries without a problem, the only difference is that I need a count number in this one. If anyone can help me out or give me a tip, I would really appreciate it.
Re: quick question on left join query
You're telling it to ORDER BY a field of the table scrusersonline that's named idcount, but there is no such field. Just remove the red part.scarface222 wrote:"SELECT scrusersonline.*, COUNT(scrusersonline.usersonlineid) AS idcount FROM scrusersonline LEFT JOIN topic ON topic.topic_id=scrusersonline.topic_id WHERE topic.subject_id='$type' scrusersonline.usersonlineusrip!='1' AND scrusersonline.id!='0' GROUP BY scrusersonline.topic_id ORDER BY scrusersonline.idcount DESC"
Anyone know why this does not work? without the join it works fine, and I have joined other queries without a problem, the only difference is that I need a count number in this one. If anyone can help me out or give me a tip, I would really appreciate it.
Re: quick question on left join query
and in addition to that...also maybe because here (in red) something is missing"SELECT scrusersonline.*, COUNT(scrusersonline.usersonlineid) AS idcount FROM scrusersonline LEFT JOIN topic ON topic.topic_id=scrusersonline.topic_id WHERE topic.subject_id='$type' scrusersonline.usersonlineusrip!='1' AND scrusersonline.id!='0' GROUP BY scrusersonline.topic_id ORDER BY scrusersonline.idcount DESC"
WHERE topic.subject_id='$type' scrusersonline.usersonlineusrip!='1' AND scrusersonline.id!='0'
Re: quick question on left join query
Good catch, mikosiko. I overlooked that omission.
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: quick question on left join query
lmao I love you guys. I will try to be much more vigilante.
Re: quick question on left join query
I think you meant vigilant...
Re: quick question on left join query
are you trying to win the "BEST SPELL CHECKER" bumper sticker ?pytrin wrote:I think you meant vigilant...
bumper sticker = that little thing in your signature
Re: quick question on left join query
this is not a misspelling, vigilante is a different word..
-
scarface222
- Forum Contributor
- Posts: 354
- Joined: Thu Mar 26, 2009 8:16 pm
Re: quick question on left join query
hahahaha pytrin you help me with my code and my grammar, you're my boy on this forum.
vigilant keenly watchful to detect danger; wary: a vigilant sentry.
vigilante any person who takes the law into his or her own hands, as by avenging a crime.
however, I did actually mean to kill criminals and to wrongfully apply the word as an adjective, so you're wrong...
vigilant keenly watchful to detect danger; wary: a vigilant sentry.
vigilante any person who takes the law into his or her own hands, as by avenging a crime.
however, I did actually mean to kill criminals and to wrongfully apply the word as an adjective, so you're wrong...
Last edited by scarface222 on Sat Feb 27, 2010 6:42 pm, edited 1 time in total.
Re: quick question on left join query
no matter.... the joke was good anyways ... c'mon... smilepytrin wrote:this is not a misspelling, vigilante is a different word..
Re: quick question on left join query
now, that would be amusinghowever, I did actually mean to kill criminals and to wrongfully apply the word as an adjective, so your wrong...