Re: Join statement and output
| From: | Cody Caughlan | Date: | Sun, 04 Mar 2001 11:12:28 +0000 |
| Subject: | Re: Join statement and output | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-7102@lists.php.net to get a copy of this message | ||
Use column-aliasing. To rename a column use the SQL "AS" syntax. Ie.
SELECT first_name AS fname ......
now "fname" is column name in the result set...Do this for each of your
first_name's, obviously using different names and you are set.
/cody caughlan
Norman Tan wrote:
> No actual code, but hopefully, someone can help me through the theory
> here.
>
> I have 2 tables:
>
> members - first_name, last_name
> schedule - member1, member2, date
>
> The SQL statement is this:
>
> select s.first_name, t.first_name, f.date from members s, members t,
> schedule f where s.first_name=f.member1 and t.first_name=f.member2
>
> Now the output would look something like this.
>
> | first_name | first_name | date |
>
> Question is, in PHP, how would I distinguish the two first_name
> fields? Database is currenly MySQL, but I would like this to be
> database independant.
>
> Thanks for your help.
> --
> Norman Tan
> North Shore Interactive
> http://www.nsmb.com
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net