Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Trying to grab from two db tables to display them with php
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Core" data-source="post: 395248" data-attributes="member: 72270"><p>[pre]<strong>SELECT</strong></p><p> <span style="color: #ff4d4d">user.username, user.look, user.motto</span>, <span style="color: #59b300">stat.Respect </span></p><p><strong>FROM</strong></p><p> <span style="color: #ff4d4d"> users user</span>, <span style="color: #59b300">user_stats stat</span></p><p><strong>WHERE</strong></p><p> <span style="color: #ff4d4d"> user.id</span> = <span style="color: #59b300">stat.<strong>user_id </strong></span></p><p><strong>ORDER BY </strong></p><p> <span style="color: #59b300">stat.Respect</span> <strong>DESC</strong></p><p><span style="color: #5900b3">LIMIT 6</span>[/pre]</p><p></p><p>You could also do</p><p></p><p>[pre]<span style="color: #ff4d4d">user.id</span> = <span style="color: #59b300">stat.<strong>user_id </strong></span><span style="color: #000000"><strong>AND</strong></span> <span style="color: #ff4d4d">user.rank</span><span style="color: #000000"> <strong>< 4</strong></span>[/pre]</p><p></p><p>Which would only show stats for users.</p><p></p><p></p><p>or using a joint query... (cba highlighting it lol) The second method is the better method.</p><p></p><p>SELECT user.username, stat.Respect FROM users user JOIN user_stats stat ON user.id = stat.user_id</p><p></p><p>I have made user_id bold because not 100% sure on the column name, my plus doesn't use the default user_stats column.</p></blockquote><p></p>
[QUOTE="Core, post: 395248, member: 72270"] [pre][B]SELECT[/B] [COLOR=#ff4d4d]user.username, user.look, user.motto[/COLOR], [COLOR=#59b300]stat.Respect [/COLOR] [B]FROM[/B] [COLOR=#ff4d4d] users user[/COLOR], [COLOR=#59b300]user_stats stat[/COLOR] [B]WHERE[/B] [COLOR=#ff4d4d] user.id[/COLOR] = [COLOR=#59b300]stat.[B]user_id [/B][/COLOR] [B]ORDER BY [/B] [COLOR=#59b300]stat.Respect[/COLOR] [B]DESC[/B] [COLOR=#5900b3]LIMIT 6[/COLOR][/pre] You could also do [pre][COLOR=#ff4d4d]user.id[/COLOR] = [COLOR=#59b300]stat.[B]user_id [/B][/COLOR][COLOR=#000000][B]AND[/B][/COLOR] [COLOR=#ff4d4d]user.rank[/COLOR][COLOR=#000000] [B]< 4[/B][/COLOR][/pre] Which would only show stats for users. or using a joint query... (cba highlighting it lol) The second method is the better method. SELECT user.username, stat.Respect FROM users user JOIN user_stats stat ON user.id = stat.user_id I have made user_id bold because not 100% sure on the column name, my plus doesn't use the default user_stats column. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Trying to grab from two db tables to display them with php
Top