Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. update
  2. contracts a,
  3. contracts_history b
  4. set
  5. a.name_surname=b.name_surname
  6.  
  7. $sql = "INSERT INTO `contracts_history`
  8. SELECT * FROM `contracts` WHERE id='$contract_id'";
  9.  
  10. mysql> use test
  11. Database changed
  12. mysql> show tables;
  13. Empty set (0.00 sec)
  14.  
  15. mysql> create table test1 (id int(2), varry varchar(3));
  16. Query OK, 0 rows affected (0.08 sec)
  17.  
  18. mysql> create table test2 (id int(2), barry varchar(3));
  19. Query OK, 0 rows affected (0.05 sec)
  20.  
  21. mysql> insert into test2 values(1,'aaa');
  22. Query OK, 1 row affected (0.00 sec)
  23.  
  24. mysql> select * from test1;
  25. Empty set (0.00 sec)
  26.  
  27. mysql> insert into test1 (select * from test2);
  28. Query OK, 1 row affected (0.06 sec)
  29. Records: 1 Duplicates: 0 Warnings: 0
  30.  
  31. mysql> select * from test1;
  32. +------+-------+
  33. | id | varry |
  34. +------+-------+
  35. | 1 | aaa |
  36. +------+-------+
  37. 1 row in set (0.00 sec)
  38.  
  39. mysql> alter table test2 add column third int(1);
  40. Query OK, 1 row affected (0.06 sec)
  41. Records: 1 Duplicates: 0 Warnings: 0
  42.  
  43. mysql> update test2 set barry='ccc';
  44. Query OK, 1 row affected (0.00 sec)
  45. Rows matched: 1 Changed: 1 Warnings: 0
  46.  
  47. mysql> insert into test1 (select * from test2);
  48. ERROR 1136 (21S01): Column count doesn't match value count at row 1
  49. mysql>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement