Bluehost.com Web Hosting $6.95

Database View combining a many-to-many

This is a discussion on Database View combining a many-to-many within the MySQL Database forums, part of the Database Forums category; I am wondering if the following is possible. I have 3 tables, one of which is merely a many-to-...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-30-2007
dean.jamieson@servicecanada.gc.ca
 
Posts: n/a
Default Database View combining a many-to-many

I am wondering if the following is possible. I have 3 tables, one of
which is merely a many-to-many join table. I want to create a View
that lists all of the primary records (players) with all of the
related values (skills) under a single column-header. See below:

Players
ID Name Height
01 John 5'1"
02 Steve 5'2"

Skills_CD
ID Desc
01 Field Goals
02 Dribbling
03 Layups
04 Blocking
05 Defense

Player_Skills
Player_ID Skills_ID
01 01
01 02
01 05
02 03
02 04

I want a single SELECT statement that can be used as a View that will
return the following:

Name Height Skills
John 5'1" Field Goals, Dribbling, Defense
Steve 5'2" Layups, Blocking

I would GREATLY appreciate any insight, even if it's someone telling
me it's impossible!

Thanks

Reply With Quote
  #2 (permalink)  
Old 01-30-2007
Captain Paralytic
 
Posts: n/a
Default Re: Database View combining a many-to-many



On 30 Jan, 13:05, dean.jamie...@servicecanada.gc.ca wrote:
> I am wondering if the following is possible. I have 3 tables, one of
> which is merely a many-to-many join table. I want to create a View
> that lists all of the primary records (players) with all of the
> related values (skills) under a single column-header. See below:
>
> Players
> ID Name Height
> 01 John 5'1"
> 02 Steve 5'2"
>
> Skills_CD
> ID Desc
> 01 Field Goals
> 02 Dribbling
> 03 Layups
> 04 Blocking
> 05 Defense
>
> Player_Skills
> Player_ID Skills_ID
> 01 01
> 01 02
> 01 05
> 02 03
> 02 04
>
> I want a single SELECT statement that can be used as a View that will
> return the following:
>
> Name Height Skills
> John 5'1" Field Goals, Dribbling, Defense
> Steve 5'2" Layups, Blocking
>
> I would GREATLY appreciate any insight, even if it's someone telling
> me it's impossible!
>
> Thanks

What you want is perfectly possible. Take a look at the GROUP_CONCAT
function

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 11:30 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0