retrieving data from multiple tables for dropdown
Hi All,
I have 3 tables, accounts, users, properties. Within the properties
add / edit pages I need to populate two select dropdowns with data
from the accounts table however I am not sure how to go about this.
TABLE INFO (basics)
ACCOUNTS
id
first_name
last_name
USERS
id
username
password
account_id
group_id
PROPERTIES
id
name
staff_id
estate_id
So both staff_id and estate_id need to have selects using the id
first_name and last_name from ACCOUNTS but staff_id will be where
group_id in users equals 3 and estate_id = 4.
The basic SQL should be as follows:
SELECT accounts.`id`, accounts.`first_name`, accounts.`last_name` FROM
accounts, users WHERE accounts.`id` = users.account_id AND
users.`group_id` = 4
Any ideas how I can go about getting this data within my properties
controller? I've googled around but I think I am more confused now
then before.
Thanks
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home