You are here: Re: want rows in 2nd (joined) table listed as columns with 1st « PHP SQL « IT news, forums, messages
Re: want rows in 2nd (joined) table listed as columns with 1st

Posted by J.O. Aho on 10/14/14 11:50

no@emails.thx wrote:
> Hi
>
> I have 2 tables ("records" and "metadata") that I can join together -
> no problem. But I want a select that brings out the columns in table
> "records" with the data in the second table also as columns. Like
> this:
>
> "records":
> id, person
> 1, 'john smith'
> 2, 'bill jones'
> 3, 'fiona wells'
>
> "metadata":
> id, recordid, data
> 1,1,'male'
> 2,1,'manager'
> 3,1,'BMW hatchback'
> 4,2,'male'
> 5,2,'cook'
> 6,3,'female'
> 7,3,'director'
> 8,3,'motorbike'
> 9,3,'company jet'
>
> (note there are not always the same number of metadata rows per
> record)
>
> I would like output similar to::
> 'john smith', 'male', 'manager', 'BMW hatchback'
> 'bill jones', 'male','cleaner'
> 'fiona wells', 'female', 'director', 'motorobike', 'company jet'

The closest you would get would be using GROUP BY and then use php to process
the data and store it in a 2D-array in the form you want the data.


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация