Log in

View Full Version : sql problem


peanut666
03-05-2005, 06:44 PM
ok i have this bit of code
############TOP country
$getstats_country = $DB_site->query("SELECT userid, username, country FROM user ORDER BY country DESC LIMIT 0, $displayrecords");
while ($getstats_country = $DB_site->fetch_array($getstats_country))
{
eval('$stats_country .= "' . fetch_template('forumhome_stats_country') . '";');
}

but when i run it i get sql error i think its cos the country field is in the userfield its one i added as a profile field its field 8

Database error in vBulletin 3.0.7:

Invalid SQL: SELECT userid, username, country FROM user ORDER BY country DESC LIMIT 0, 10 mysql error: Unknown column 'country' in 'field list'

is it the code or the field 8 i should be calling

the aim is to list the top countrys

thanks for any help

Guest190829
03-05-2005, 06:54 PM
I think it's field 8 you should be calling, but I'm only beggining to learn MySQL...

Adrian Schneider
03-05-2005, 06:56 PM
SELECT user.userid, user.username, userfield.field8
FROM user
LEFT JOIN userfield ON user.userid=userfield.userid
ORDER BY userfield.field8 DESC
LIMIT 0

Heres an updated version of your query assuming country is field8.