Welcome Guest, Not a member yet? Register   Sign In
How to make this query a little bit more readable?
#6

(This post was last modified: 03-18-2017, 07:41 PM by John_Betong.)

(03-18-2017, 05:39 PM)Try PHP heredoc Wrote:
PHP Code:
/*
 BEWARE ONLY LINEFEED AFTER FIRST ____TMP AND ; AFTER LAST ____TMP
 NO SPACES ALLOWED OTHERWISE SYNTAX ERROR :(
*/

$sql = <<< ____TMP

SELECT 
  a.id,
  b.id AS employee_id,
  CONCAT
  (
    b.last_name,
    ', ',
    b.first_name,
    ' ',
    b.middle_name
  )
  AS full_name,
  c.id AS machine_id,
  c.title AS machine,
  d.title AS hstatus,
  a.created_on,
  a.action_on,
  a.edit_on,
  a.problems_encountered,
  a.corrective_action,
  a.root_caused,
  a.remarks,
  a.item_replaced 
FROM
  reports AS a 
  LEFT JOIN employees AS b 
    ON b.id = a.employee_id 
  LEFT JOIN machines AS c 
    ON c.id = a.machine_id 
  LEFT JOIN hstatus AS d 
    ON d.id = a.hstatus_id 
____TMP;

$query $this->db->query($sql); 
Reply


Messages In This Thread
RE: How to make this query a little bit more readable? - by John_Betong - 03-18-2017, 07:39 PM



Theme © iAndrew 2016 - Forum software by © MyBB