Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 23rd, 2012  |  syntax: None  |  size: 1.22 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Combining three mysql statements
  2. SELECT pageid FROM thepage WHERE DATE(createdate)='2011-11-09' ORDER BY createdate DESC
  3.  
  4. SELECT urlid FROM themix WHERE pageid=...
  5.  
  6. SELECT link FROM theurl WHERE urlid=...
  7.        
  8. SELECT p.pageid
  9.      , u.link
  10. FROM thepage p INNER JOIN themix m
  11.     ON p.pageid = m.pageid
  12. INNER JOIN theurl u
  13.     ON m.urlid = u.urlid
  14. WHERE DATE(p.createdate) = '2011-11-09'
  15. ORDER BY p.createdate DESC
  16.        
  17. SELECT u.link
  18. FROM thepage p
  19.   INNER JOIN themix m
  20.     ON p.pageid = m.pageid
  21.   INNER JOIN theurl u
  22.     ON m.urlid = u.urlid
  23. WHERE DATE(p.createdate) = '2011-11-09'
  24. GROUP BY m.urlid
  25. ORDER BY MIN(p.createdate) DESC
  26.        
  27. WHERE DATE(p.createdate) = '2011-11-09'
  28.        
  29. WHERE p.createdate = '2011-11-09'
  30.        
  31. WHERE p.createdate >= '2011-11-09'
  32.   AND p.createdate < '2011-11-10'
  33.        
  34. SELECT url.link
  35. FROM page
  36.   INNER JOIN mix
  37.     ON page.pageid = mix.pageid
  38.   INNER JOIN url
  39.     ON mix.urlid = url.urlid
  40. WHERE DATE(page.createdate) = '2011-11-09'
  41. ORDER BY page.createdate DESC
  42.        
  43. SELECT
  44.     theurl.link  
  45. FROM
  46.     thepage  
  47. LEFT JOIN
  48.     themix
  49. ON
  50.     thepage.pageid = urlid.pageid
  51. LEFT JOIN
  52.     theurl
  53. ON
  54.     theurl.urlid = themix.urlid
  55. WHERE
  56.     DATE(thepage.createdate)='2011-11-09'
  57. ORDER BY
  58.     thepage.createdate DESC