Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. SELECT a.tabl1, b.tabl2, c.tabl3
  2. INTO OUTFILE 'H:/output/output.csv'
  3. fields TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY 'n'
  4. FROM a, b, c
  5. INNER JOIN a.tabl1 ON a.id = b.id
  6. INNER JOIN b.tabl2 ON b.id = c.id
  7. WHERE
  8. (
  9.  
  10. b.case_txt = 'case1' OR
  11. b.case_txt = 'case2' OR
  12. b.case_txt = 'case3' OR
  13. )
  14.  
  15. AND
  16. c.address != ''
  17. AND
  18. c.state = 'OR'
  19. AND
  20. date LIKE '%02/01/13%';
  21.  
  22. SELECT a.*, b.*, c.*
  23. INTO OUTFILE 'H:/output/output.csv'
  24. fields TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY 'n'
  25. FROM tabl1 a
  26. INNER JOIN tabl2 b ON a.id = b.id
  27. INNER JOIN tabl3 c ON b.id = c.id
  28. WHERE
  29. (
  30. b.case_txt = 'case1' OR
  31. b.case_txt = 'case2' OR
  32. b.case_txt = 'case3'
  33. )
  34.  
  35. FROM a, b, c -- cartesian product of these three tables joined with
  36. INNER JOIN a.tabl1 ON a.id = b.id -- nonexisting tables a.tabl1 (table tabl1 in db a)
  37. INNER JOIN b.tabl2 ON b.id = c.id -- and tabl2 in database b
  38.  
  39. FROM a
  40. INNER JOIN b ON a.id = b.id
  41. INNER JOIN c ON b.id = c.id
  42.  
  43. SELECT *
  44. INTO OUTFILE 'H:/output/output.csv'
  45. fields TERMINATED BY ','
  46. OPTIONALLY ENCLOSED BY '"'
  47. LINES TERMINATED BY 'n'
  48. FROM tabl1 AS a
  49. INNER JOIN tabl2 AS b
  50. ON a.id = b.id
  51. INNER JOIN tabl3 AS c
  52. ON b.id = c.id
  53. WHERE (
  54. b.case_txt = 'case1' OR
  55. b.case_txt = 'case2' OR
  56. b.case_txt = 'case3'
  57. )
  58. AND c.address != ''
  59. AND c.state = 'OR'
  60. AND date LIKE '%02/01/13%';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement