Is there any reason NOT to wrap a long query over multiple line via new lines vs using concatenation?For example, consider this:$this->query(SELECT u.*, COALESCE(c2.name,u.state) AS real_state, c.name AS real_country, bc.alpha3 AS country_iso, bs.code AS state_iso                    FROM  . MAIN_DB . .users AS u                    INNER JOIN  . MAIN_DB . .countries AS c ON u.country=c.id                     LEFT JOIN  . MAIN_DB . .countries AS c2 ON u.state=c2.id                     LEFT JOIN  . BLESTA_DB . .countries AS bc ON c.country_iso_code=bc.alpha2                    LEFT JOIN  . BLESTA_DB . .states AS bs ON bc.alpha2=bs.country_alpha2 AND COALESCE(c2.name,u.state)=bs.name                    WHERE u.active=1 AND u.mail_activated=1 AND u.blesta_id=0);VS$this->query(SELECT u.*, COALESCE(c2.name,u.state) AS real_state, c.name AS real_country, bc.alpha3 AS country_iso, bs.code AS state_iso  .                     FROM  . MAIN_DB . .users AS u  .                     INNER JOIN  . MAIN_DB . .countries AS c ON u.country=c.id  .                     LEFT JOIN  . MAIN_DB . .countries AS c2 ON u.state=c2.id  .                     LEFT JOIN  . BLESTA_DB . .countries AS bc ON c.country_iso_code=bc.alpha2  .                     LEFT JOIN  . BLESTA_DB . .states AS bs ON bc.alpha2=bs.country_alpha2 AND COALESCE(c2.name,u.state)=bs.name  .                     WHERE u.active=1 AND u.mail_activated=1 AND u.blesta_id=0);Are there any possible problems with the first code or is either fine?
MySQL query to find country and state of active users
php;mysql;comparative review
COALESCE(c2.name,u.state) AS real_state seems bizarre. That would cause the user's country to always override the user's state.  Perhaps you got the parameters reversed?As for the code formatting, it's mostly a matter of opinion. There might be a tiny difference in performance, but given the other string concatenations that you are already doing, plus the fact that the execution of the query will completely dominate the running time anyway, it ends up being purely a matter of opinion.