I have 2 models Scale and Step, where model Scale has many Step.
The db tables are:
scale : id | name | s1 | s2 | s3 | s4 | s5 | s6 | s7
step : id | val
I want to write the following query in cakephp structure…
select s.id, s1.val as v1, s2.val as v2, s3.val as v3, s4.val as v4, s5.val as v5, s6.val as v6, s7.val as v7
from scale s
join step s1 on s.s1 = s1.id
join step s2 on s.s2 = s2.id
join step s3 on s.s3 = s3.id
join step s4 on s.s4 = s4.id
join step s5 on s.s5 = s5.id
join step s6 on s.s6 = s6.id
join step s7 on s.s7 = s7.id
Can you please help me with the syntax??
1 Answer