Guest User

Untitled

a guest
Jan 17th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. tb_wrapper tb_author
  2. ================= ==================
  3. |id| title | url| |id|author|$title|
  4. ================= ==================
  5. |1 |titleA |urlA| | 1| A |titleA|
  6. ================= | 2| B |titleA|
  7. ===================
  8.  
  9. ======================
  10. |id | content | title|
  11. ======================
  12. |1 | contentA|titleA|
  13. ======================
  14.  
  15. $query = mysql_query("SELECT
  16. tb_wrapper.url,
  17. tb_wrapper.title,
  18. tb_author.title,
  19. tb_author.author,
  20. tb_doc.content,
  21. tb_doc.title
  22. FROM
  23. tb_doc
  24. INNER JOIN tb_wrapper ON tb_doc.title = tb_wrapper.title
  25. INNER JOIN tb_author ON tb_wrapper.title = tb_author.title ");
  26.  
  27. SELECT w.url, w.title, a.title, a.authors,
  28. d.content, d.title
  29. FROM tb_doc d
  30. INNER JOIN tb_wrapper w ON d.title = w.title
  31. INNER JOIN
  32. (
  33. SELECT title, GROUP_CONCAT(author SEPARATOR ', ') AS authors
  34. FROM tb_author
  35. GROUP BY title
  36. ) a ON w.title = a.title
Add Comment
Please, Sign In to add comment