Re: One to Many Select Statement

From: Date: Mon, 13 Sep 2004 08:03:07 +0000
Subject: Re: One to Many Select Statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-36166@lists.php.net to get a copy of this message
My suggestion is: select u.username, g.group_name from usertable u inner join grouptable g on u.id=g.user_id; ENJOY !! Arné Klopper System Developer NetCB Solution(Pty) Ltd. www.netcb.com ************************************** Looking for clarification... Say that I have a user table and group table -> -- user table -- id username 1 foo -- group table -- id user_id group_name 1 1 group_1 2 1 group_2 Would this be the proper way to construct a select statement for this -> select u.username, g.group_name from user u, group g where u.user.id = g.user_id and user.id = 1; The results should look like this -> username group_name foo group 1 foo group 2 What I would like to clarify, is if this is the proper (only) way to construct a one to many select statement? I've always thought I was doing something illegal, since username is displayed more than once, and I would like to shake that thought off my back. Thanks for your input..

« previous php.db (#36166) next »