Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   CentOS (http://www.linux-archive.org/centos/)
-   -   I need some help joining data from 3 MySQL tables, please (http://www.linux-archive.org/centos/364561-i-need-some-help-joining-data-3-mysql-tables-please.html)

Les Mikesell 05-01-2010 03:15 PM

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


All times are GMT. The time now is 05:09 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.