"and Branch belongsTo Company (without that, there's no correlation
Company and Branch) "

and again you'd be duplicating information ;-)

You could get a list of branches for each company via the users table

Get branches for company:

SELECT DISTINCT branches.id, branches.name
FROM branches
INNER JOIN users
ON users.branch_id=branch.id
INNER JOIN companies
ON users.company_id=companies.id
WHERE company.id=???

Get users in company:

SELECT users.id, users.name
FROM users
WHERE users.company_id=???

Get Users in a branch:

SELECT users.id, users.name
FROM users
WHERE users.branch_id = ???

Note: I've done all this in my head so there's bound the be errors :-D


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to