janim Posted December 25, 2007 Share Posted December 25, 2007 hi guys i have trouble in joining tables together lets say i have two tables : singers and songs . ******** singers table : id name 1 eminem 2 akon 3 shaggy ******** songs table: id song 1 smack that 2 sexy 3 lose your self 4 till i collapse 5 lonely etc.... so how can i join those tables ???? every singer has a lot of songs and every song has a lot of singers too let's take example here smack that by eminem and akon so i can't put another row in the songs table for the singer name please help this is gonna kill me Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/ Share on other sites More sharing options...
revraz Posted December 25, 2007 Share Posted December 25, 2007 You either need a singer field in the songlist or a song field in the singer list. Then you can join them by ID. Singer list in the songlist would probably be better. Or a third table that has song and singers in the fields. Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423070 Share on other sites More sharing options...
janim Posted December 25, 2007 Author Share Posted December 25, 2007 thank you revraz for your replay but i don't think it could be done this way couse there are alot of songs for every singer and i want to link this entries later Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423077 Share on other sites More sharing options...
revraz Posted December 25, 2007 Share Posted December 25, 2007 That's how you link them. You need to make a connection somehow. How else are you going to determine what singer sang what song? Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423083 Share on other sites More sharing options...
janim Posted December 25, 2007 Author Share Posted December 25, 2007 yes that's what i'm asking about !!!! Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423095 Share on other sites More sharing options...
wayne Posted December 26, 2007 Share Posted December 26, 2007 As Revraz has said you need to add further details singers table : id name 1 eminem 2 akon 3 shaggy ******** songs table: id song name 1 smack that eminem 2 smack that akon 3 sexy 4 lose your self 5 till i collapse 6 lonely select * from singers a, songs b where name a = name b etc.... Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423099 Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 There is no magic wand that will help you. Link them either in your existing table or make a new one to link them. yes that's what i'm asking about !!!! Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423100 Share on other sites More sharing options...
janim Posted December 26, 2007 Author Share Posted December 26, 2007 yes i'm little confused about this let;s say i will put another filed in songs table for the singers in some row there is 3 singers then how can i link it ? ??? Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423105 Share on other sites More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 You would either have to list it 3 times or use a third table: songs Table id | name artist Table id | name Listing Table song.id | artist.id Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-423107 Share on other sites More sharing options...
fenway Posted December 27, 2007 Share Posted December 27, 2007 You would either have to list it 3 times or use a third table: songs Table id | name artist Table id | name Listing Table song.id | artist.id 3 times? No! Use a third many-to-many table as suggested. Quote Link to comment https://forums.phpfreaks.com/topic/83173-join-tables-problem/#findComment-424086 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.