Re: [PHP-DB] Select from multiple tables

2012-03-01 Thread Kranthi Krishna
Kranthi. http://goo.gl/e6t3 On 1 March 2012 21:47, Carl Michael Skog cms...@gmail.com wrote: -- Vidarebefordrat meddelande -- Från: Carl Michael Skog cms...@gmail.com Datum: 1 mars 2012 17:12 Ämne: Re: [PHP-DB] Select from multiple tables Till: Kranthi Krishna kranthi

Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Matijn Woudt
On Wed, Feb 29, 2012 at 3:01 PM, Kranthi Krishna kranthi...@gmail.com wrote: Hi all, Say I have an object like array    schoolName = string    board = array         string         string I generally create  two MySql tables schools: id PRIMARY KEY, SchoolName boards: id FOREGIN KEY

Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Kranthi Krishna
Hi, Thanks for the input. I have seen some tutorials on joins, they all suggest that MySql returns multiple rows For example -- School | Board 1 -- School | Board 1 - Now if I have another one-to-many relation

Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Kranthi Krishna
Hi, The examples I saw were regarding cartesian join not inner join. I will read about inner joins. Also, the example i mentioned seems to be a mistake. Both school and type will not be similar at the same time Kranthi. http://goo.gl/e6t3 On 1 March 2012 09:26, Kranthi Krishna

Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Amit Tandon
Dear Kranthi You have to be clear what you decide especially when you are getting multiple rows. To get just a single row you can use LIMIT clause. But it would return only one row. Now you have to decide which row. So i think you decide on what you require and see how can you uniquely

Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Karl DeSaulniers
Try DISTINCT On Feb 29, 2012, at 10:28 PM, Amit Tandon wrote: Dear Kranthi You have to be clear what you decide especially when you are getting multiple rows. To get just a single row you can use LIMIT clause. But it would return only one row. Now you have to decide which row. So i think

Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Kranthi Krishna
Hi all, SELECT DISTINCT s.Title, b.Board_id, t.type FROM school s, board_entries b, schooltypeentries t WHERE s.School_id = 1698 AND b.School_id = 1698 AND t.schoolid = 1698 this SQL query gives me Kendriya Vidyalaya 15 Kick Boxing Kendriya Vidyalaya 15 Karate Kendriya

Re: [PHP-DB] Select from multiple tables

2012-02-29 Thread Karl DeSaulniers
This is just a stab in the dark and may be in the wrong order. If it does not work I apologize. SELECT s.Title, (SELECT DISTINCT b.Board_id), (SELECT DISTINCT t.type), (SELECT s.School_id AND b.School_id AND t.schoolid AS id ) FROM school s, board_entries b, schooltypeentries t WHERE id =