如何只将不同的值插入MySQL表?

时间:2016-08-25 07:22:36

标签: javascript mysql google-cloud-sql

我使用Google Apps ScriptGoogle Cloud SQL更新MySQL表格,我不想插入重复值,例如:

如果我有下表和记录

+----+--------+-----------+-------+
| id | name   | address   | phone |
+----+--------+-----------+-------+
|  1 | John   | Somewhere | 022   |
+----+--------+-----------+-------+
|  2 | Snow   | North     | 023   |
+----+--------+-----------+-------+

然后我不能执行插入新记录

的查询
name=John, 
address=Somewhere,
phone=022

name=Snow,
address=North,
phone=023

这是我当前的代码,它将新记录插入数据库:

  var stmt = conn.prepareStatement('INSERT INTO entries '
      + '(name, address, phone) values (?, ?, ?)');

  stmt.setString(1, "John");
  stmt.setString(2, "Snow");
  stmt.setString(3, 022);
  stmt.execute();

0 个答案:

没有答案