Forum Moderators: coopster
I have two questions regarding using PHP with MySQL:
1- I have a number of queries that I currently keep in a file named queries.sql. However, is there a best practice for keeping queries somewhere? In a table, in a file, in the PHP code as an array, in the PHP code as separate variables?
2- What is the best way of implementing nested queries in PHP using MySQL v4.0 (ie no views) in the case where using INNER/LEFT JOINs would make the query horrendously complex? I really prefer to be able to use intermediate results and execute the subsequent queries on that result. With "result" I mean something like $result = mysql_query($sql);
Thanks in advance
Tech
You can also use user variables which will eliminate some overhead:
[dev.mysql.com...]
Sean
The queries I am talking about are a good paragraph in length, which from a maintenance standpoint will probably require a fair bit of editing. Hence my latent need for views.
User comments on the webpage you kindly pointed to, indicate that no aggregates can be used in combination with variables. My queries are teeming with AVGs and MAXs however, so I am not sure whether that would be the way to go.
Thanks again
Tech