Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.63 KB | None | 0 0
  1. SELECT
  2.     u.name AS source,
  3.     u2.name AS target
  4. FROM
  5.     board_posts AS p
  6.  
  7. /* Get user data for the post */
  8. LEFT JOIN board_users AS u
  9. ON u.id = p.author_id
  10.  
  11. /* Try to get user data for the user inside quotation marks */
  12. LEFT JOIN board_users AS u2
  13. ON u2.name = substring_index(
  14.     substring_index(p.message, '[quote="', - 1),
  15.     '"]',
  16.     1
  17. )
  18. /* CHAR(7) is the unicode I used to separate different previous names */
  19. OR LEFT(u2.other_names, LOCATE(CONCAT("", CHAR(7), ""), u2.other_names) - 1) = substring_index(substring_index(p.message, '[quote="', - 1), '"]', 1)
  20.  
  21. WHERE
  22.     LOWER(p.message) LIKE '[quote="%'
  23. ORDER BY
  24.     p.id DESC
  25. LIMIT 50
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement