My ETernal Clan homepage project

Get Help, Tips & Tutorials on Using Your Computer.

Re: My ETernal Clan homepage project

Postby MaTT » Wed Mar 26, 2014 9:40 pm

That SQL query looks unnecessarily complicated. First of all, i've never encountered SQL queries with "AS g" or "AS u" although looking at this query I think I have an idea about what they do. Secondly, if you are going to be listing it in the same format as the output you posted, you won't need to query all the database table fields. Thirdly, the "group_id" field in your "et_users" table is a foreign key of the primary key "group_id" (basically an exact copy of) in your "et_groups" table so when you use "WHERE u.group_id = g.group_id" it will only return all of the results in your "et_users" table, so you don't need that part.

Try this instead:
Code: Select all
SELECT username, user_posts, g.group_id, g.group_name FROM et_users, et_groups WHERE u.group_id=2 ORDER BY username


(Note: I haven't tested the query. I'm pretty sure it will work, but don't be surprised if it doesn't work :p)
Image
Image Image Image Image Image Image
The Most Astounding Fact || Window on the Universe
Image
#ETernal Clan Founder - Contact me
Since 13/4/2011 (6 Years)
User avatar
MaTT
.
 
Posts: 3805
Joined: Fri Jun 17, 2011 12:07 pm
Location: England, East Sussex
Home-Game: Wolfenstein Enemy Territory
Favourite Weapon: Giulietta
Wolfenstein ET Name: #ET|TitaN*|
Steam Name: Mattipoika
Clan Wars: 0

Re: My ETernal Clan homepage project

Postby Ziltoid » Wed Mar 26, 2014 9:53 pm

It doesn't work, and I know why.

Because I'm using data from multiple tables, you need to define from which table you're selecting. That's why I use 'users AS u' and 'groups AS g'. If I type u.username, it will know it has to look in the table 'users' for the field 'username'. If I don't use it, the database doesn't know where to look for 'username' and thus returns nothing. Same goes for the 'groups AS g' part.

Then why I put WHERE u.group_id = g.group_id. I'm looking in two different tables, which happen to have a record with the same name and value (foreign and primary key as you said). If you don't tell the database that 'u.group_id' is the same as 'g.group_id', it will return everything double. If I add that part though, it will only return it once.

It may look strange, but this is what has to be done in order to get the right data. I get the data I want, in the way I want it, just 'furious' is not ordered by username..

Thanks for the help though :)
Image

~~GOD OF MASTURBATION~~

#MattEgeFennyWorstLT

I used to have nice signatures, then Photobucket went full retard.
User avatar
Ziltoid
.
 
Posts: 2976
Joined: Sat Oct 22, 2011 5:24 pm
Location: The Netherlands
Home-Game: Wolfenstein Enemy Territory
Wolfenstein ET Name: #ET|Ziltoid
Steam Name: SaltboxMetal
Clan Wars: 0

Re: My ETernal Clan homepage project

Postby Ziltoid » Sat Mar 29, 2014 8:35 pm

What I've been working on today:
A different style for the member list:
http://alexvd.pcnerd.nl/et/members.php
And a sidebar showing the last five created topics:
http://alexvd.pcnerd.nl/et/index.php

Both still need some work, but they're functional at the moment.

Any comments on them?
Image

~~GOD OF MASTURBATION~~

#MattEgeFennyWorstLT

I used to have nice signatures, then Photobucket went full retard.
User avatar
Ziltoid
.
 
Posts: 2976
Joined: Sat Oct 22, 2011 5:24 pm
Location: The Netherlands
Home-Game: Wolfenstein Enemy Territory
Wolfenstein ET Name: #ET|Ziltoid
Steam Name: SaltboxMetal
Clan Wars: 0

Re: My ETernal Clan homepage project

Postby Unit » Tue Apr 01, 2014 6:14 am

Very nice :)

Is what you're working on going to be the new forums? :ask:
Image

"People die if they are killed" - A philosopher of the ages.
User avatar
Unit
.
 
Posts: 2506
Joined: Wed Feb 06, 2013 7:55 pm
Location: The Gates of Dawn
Home-Game: Wolfenstein Enemy Territory
Favourite Weapon: Super Shotgun
Wolfenstein ET Name: #ET|Unit
Steam Name: Unitron
Clan Wars: 0

Re: My ETernal Clan homepage project

Postby Ziltoid » Tue Apr 01, 2014 9:53 am

Thanks :)

And no, I'm (and later Matt will too) only working on the site. This has nothing to do with the forum :P We will try some integration between the forum and site though :)
Image

~~GOD OF MASTURBATION~~

#MattEgeFennyWorstLT

I used to have nice signatures, then Photobucket went full retard.
User avatar
Ziltoid
.
 
Posts: 2976
Joined: Sat Oct 22, 2011 5:24 pm
Location: The Netherlands
Home-Game: Wolfenstein Enemy Territory
Wolfenstein ET Name: #ET|Ziltoid
Steam Name: SaltboxMetal
Clan Wars: 0

Previous

Return to Hardware/Software

  • Advertisement