SHARE
TWEET

Untitled

a guest Jun 25th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.   id,
  3.   name,
  4.   group_concat(
  5.     DISTINCT concat( number, ' (', phones.description, ')' )
  6.     ORDER BY phones.description
  7.     SEPARATOR '<br>'
  8.   ) AS phones,
  9.   group_concat(
  10.     DISTINCT concat( email, ' (', emails.description, ')' )
  11.     ORDER BY emails.description
  12.     SEPARATOR '<br>'
  13.   ) AS emails,
  14.   group_concat(
  15.     DISTINCT concat( address, ' (', addresses.description, ')' )
  16.     ORDER BY addresses.description
  17.     SEPARATOR '<br>'
  18.   ) AS addresses
  19.  
  20. FROM people
  21. LEFT OUTER JOIN phones
  22.   ON phones.person_id = id
  23. LEFT OUTER JOIN emails
  24.   ON emails.person_id = id
  25. LEFT OUTER JOIN addresses
  26.   ON addresses.person_id = id
  27.  
  28. WHERE id IN (
  29.   SELECT DISTINCT person_id
  30.   FROM phones
  31.   WHERE number LIKE ?
  32.   AND person_id IN (
  33.     SELECT DISTINCT person_id
  34.     FROM emails
  35.     WHERE email LIKE ?
  36.     AND person_id IN (
  37.       SELECT DISTINCT person_id
  38.       FROM addresses
  39.       WHERE address LIKE ?
  40.     )
  41.   )
  42. )
  43. AND name LIKE ?
  44. GROUP BY id
  45. ORDER BY id DESC;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top