Welcome Guest, Not a member yet? Register   Sign In
Many-to-Many Relationships & Active Record Class
#7

[eluser]Chris Newton[/eluser]
tonanbarbarian;
Right, but how would you write the sql query for that?

Ex;

Table A has 2 rows (news items)
Table B has 25 rows (category names)
Crossover table X has 17 rows, 13 of which relate to table A, 4 of which relate to table B

So.... how do you write a join that does the following; Respects the fact that there are only 2 items I'm interested in from table A (the news items), while adding an array of their corresponding categories stored in table X with names referenced in table B?

Every join that I could come up with ended up displaying multiple copies of the items from table A each with 1 category assigned to them. (rather than only 2 rows)

I could join everything, and then loop through it to pull out only the category information from multiple instances of the same data but that doesn't sound much better. Anyway. I'm gonna go try something... brb.


Messages In This Thread
Many-to-Many Relationships & Active Record Class - by El Forum - 11-27-2007, 09:00 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-27-2007, 10:07 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-27-2007, 10:16 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-27-2007, 11:32 PM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 02:44 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 03:00 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 08:41 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 09:00 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 10:07 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 11:02 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 11:49 AM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 12:33 PM
Many-to-Many Relationships & Active Record Class - by El Forum - 11-28-2007, 08:46 PM
Many-to-Many Relationships & Active Record Class - by El Forum - 12-05-2007, 11:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB