FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 05-01-2010, 03:15 PM
Les Mikesell
 
Default I need some help joining data from 3 MySQL tables, please

Rudi Ahlers wrote:
>
>
> A google search results suggested the alias should be put after the
> bracket. So, I change the code as follow, and move the *AS `u`* outside
> the right bracket:
>
> SELECT c . * , COUNT( m.id ) AS `members`
> FROM `jos_mls_teams` AS `c`
> LEFT JOIN `jos_mls_teams_members` AS `m` ON m.teamid = c.id
> RIGHT JOIN ( SELECT u.name, u.lastvisitDate FROM `jos_users` ) AS `u`
> ON u.id = m.userid
> GROUP BY c.id
> LIMIT 0 , 30
>
> But then I get the error:
>
> #1054 - Unknown column 'u.name <http://u.name>' in 'field list'

Inside the subquery, the table is jos_users (and since there is only one you
shouldn't even have to specify it. The 'u' alias is a temporary table holding
the result from the subquery.

--
Les Mikesell
lesmikesell@gmail.com

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 

Thread Tools




All times are GMT. The time now is 12:51 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org