TeamTable
+-------------------+
| id         | name  |
+-------------------+
| 1          | blue    |
| 2          | green |
+-------------------|

PersonTable
+------------------+
| id         | name |
+------------------+
| 4          | john  |
| 5          | bill     |
+---------+-------+

TeamPersonTable
+-----------------------+
| teamId | personId |
+-----------------------+
| 1          | 4          |
| 1          | 5          |
| 2          | 4          |
| 2          | 5          |
+---------+----------+

So a person can belong to any teams.


Query Input:  teamId = 1

Result:

personNames = "john,bill"
personIds = "4,5"




On 5/22/14, RSmith [via SQLite] <ml-node+s1065341n75776...@n5.nabble.com> wrote:
>
>
>
> On 2014/05/22 13:02, Humblebee wrote:
>> @RSmith,
>>
>> Very much appreciate you taking the time to write such a detailed and
>> awesome explanation of how the string and list works in SQL.  I had no
>> idea what goes on there.
>>
>
> It is my pleasure, sadly I know exactly how it feels to be under the wrong
> impression (I have been so on this very list!).
>
>> As for now, I'm following the good advice of all the much more
>> knowledgeable people on this list to normalize the data by adding a
>> Person_Team table to the database.  My last question is what SQL
>> statement could I use to get the information out of these 3 tables.
>
> That is great news- I promise you will not be sorry. As for the question,
> once you decided how the tables will look, could you again
> paste them here with a little bit of example data in each and then say
> exactly how you want the resulting data to look after the
> query is run - and we will try suggest the most optimized ways of achieving
> it. A bit of knowledge about how often the tables will
> be updated/inserted to, and how often the query will be run, and how much
> every table is expected to grow over time, would all help
> to make the best decisions.
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>
>
>
> _______________________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://sqlite.1065341.n5.nabble.com/Simple-Select-from-IN-from-a-newbie-tp75751p75776.html
>
> To unsubscribe from Simple Select from IN - from a newbie., visit
> http://sqlite.1065341.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=75751&code=ZmFudGFzaWEuZG9zYUBnbWFpbC5jb218NzU3NTF8MTk4Njk4NTgwNw==




--
View this message in context: 
http://sqlite.1065341.n5.nabble.com/Simple-Select-from-IN-from-a-newbie-tp75751p75778.html
Sent from the SQLite mailing list archive at Nabble.com.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to