Reputation: 61
These are my mysql queries.. I hope you can give some answer.
SELECT a.*,
c.name AS barangay_name,
d.name AS municipal_name,
e.name AS province_name,
f.name AS region_name
FROM location a
INNER JOIN barangay c ON c.id = a.barangay_id
LEFT JOIN municipal d ON d.id = c.municipal_id
LEFT JOIN province e ON e.id = d.province_id
LEFT JOIN region f ON f.id = e.region_id
ORDER BY TRIM(a.name) ASC
Upvotes: 1
Views: 150
Reputation: 3464
I will just leave this here:
http://www.yiiframework.com/doc/guide/1.1/en/database.query-builder
Good luck :)
Upvotes: 2