Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. mysql> use test;
  2. Database changed
  3. mysql> select * from t1;
  4. +----+------+
  5. | id | val |
  6. +----+------+
  7. | 1 | 100 |
  8. | 2 | 200 |
  9. +----+------+
  10. 2 rows in set (0.00 sec)
  11.  
  12. mysql> select * from t2;
  13. +----+-------+
  14. | id | val |
  15. +----+-------+
  16. | -1 | -1000 |
  17. | 1 | 1000 |
  18. | 3 | 3000 |
  19. +----+-------+
  20. 3 rows in set (0.00 sec)
  21.  
  22. mysql> create or replace view iid as select id from t1 union select id from t2;select iid.id,t1.val,t2.val from iid left join t1 on iid.id=t1.id left join t2 on iid.id=t2.id;
  23. Query OK, 0 rows affected (0.07 sec)
  24.  
  25. +----+------+-------+
  26. | id | val | val |
  27. +----+------+-------+
  28. | 1 | 100 | 1000 |
  29. | 2 | 200 | NULL |
  30. | -1 | NULL | -1000 |
  31. | 3 | NULL | 3000 |
  32. +----+------+-------+
  33. 4 rows in set (0.00 sec)
  34.  
  35. >> sqlCmd = ['create or replace view iid as select id from t1 union select id from t2;',...
  36. 'select iid.id,t1.val,t2.val from iid',...
  37. ' left join t1 on iid.id=t1.id',...
  38. ' left join t2 on iid.id=t2.id'];
  39.  
  40. conn = database('test','root','198471',...
  41. 'com.mysql.jdbc.Driver','jdbc:mysql://127.0.0.1:3306/test');
  42. >> curs = exec(conn,sqlCmd);
  43. >> curs.Message
  44. ans =
  45. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select iid.id,t1.val,t2.val from iid left join t1 on iid.id=t1.id left join t2 o' at line 1
  46. >> curs = exec(conn,'select * from t1');
  47. >> curs = fetch(curs);
  48. >> curs.Data
  49. ans =
  50. 1 100
  51. 2 200
  52. >> sqlCmd
  53.  
  54. sqlCmd = 'create or replace view iid as select id from t1 union select id from t2;select iid.id,t1.val,t2.val from iid left join t1 on iid.id=t1.id left join t2 on iid.id=t2.id;';
  55. curs = exec(conn,sqlCmd);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement