Guest User

Untitled

a guest
Jan 15th, 2018
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT p1.ID AS car_1, p2.ID AS car_2 FROM `compares`
  2.                 LEFT JOIN wp_term_relationships t1 ON t1.object_id = compares.car_id_1
  3.                 LEFT JOIN wp_term_relationships t2 ON t2.object_id = compares.car_id_2
  4.                 LEFT JOIN wp_posts p1 ON t1.object_id = p1.ID
  5.                 LEFT JOIN wp_posts p2 ON t2.object_id = p2.ID
  6.                 LEFT JOIN wp_postmeta m1 ON m1.post_id = p1.ID
  7.                 LEFT JOIN wp_postmeta m2 ON m2.post_id = p2.ID
  8.                 WHERE
  9.                 t1.object_id = compares.car_id_1 AND
  10.                 t2.object_id = compares.car_id_2 AND
  11.                 t1.term_taxonomy_id = %d AND
  12.                 t2.term_taxonomy_id = %d AND
  13.                 m1.meta_key = 'поколение' AND
  14.                 m1.meta_value = 1 AND
  15.                 m2.meta_key = 'поколение' AND
  16.                 m2.meta_value = 1
  17.                
  18.                 ORDER BY compares.COUNT DESC
  19.                 LIMIT 4
RAW Paste Data