1. LEFT JOIN is sometimes the only way to get proper query results. It is sometimes also faster than complex WHERE queries.
  2. ".TB_PREF." should be used only to refer to tables and not to fields. Use the table.field construct to refer to fields where there is ambiguity in field names or where table source is not easily discerned.
  3. Avoid aliasing table names unless the same table is used more than once in the same SQL statement. Alias them if table names are too long or not easily understood. In such cases use one alias for each table consistently throughout the codebase.
  4. Improve SQL readability by using IN (".implode(',', ...).") form than multiple OR-ed comparisions for 3 and more elements.
  5. Prefer InnoDB tables over MyISAM where transactions are envisaged. The only advantage of MyISAM over InnoDB is full-text search, which we do not use in FA anyway.
  6. Use 4 space indents instead of tabs for uniform rendering across applications and web displays.