In my mysql db I have a "4 level parent table" and when I use them in php I wouldn't like to write everytime the multiple join... Example
select ... FROM tableA
INNER JOIN tableB ON (tableA.id = tableB.idA) INNER
JOIN tableC ON (tableB.id = tableC.idB)...
when I use them in php I wouldn't like to write everytime the multiple join.
Consider creating a VIEW
then with your query like below and use that view in PHP
code
create view vw_multilevelquery as
select ... FROM tableA
INNER JOIN tableB ON (tableA.id = tableB.idA)
INNER JOIN tableC ON (tableB.id = tableC.idB)...
In your PHP
code just perform a SELECT
on created view like
select * from vw_multilevelquery;
Look into using stored procedures as shorthand for queries with variables.
https://dev.mysql.com/doc/refman/5.0/en/create-procedure.html
The benefit over using a view is full use of the WHERE filter.
When querying a view, the optimiser may decide to do
select * from (select ... from ...) where col=value
while when using a stored procedure, you will have
select ... from ... where col=value
the performance difference may be significant.