mysql - 从特定日期插入 SQL

标签 mysql sql

我在 SQL 数据库中有类时间表。

INSERT INTO schedule (date)
  VALUES
  ('2016-05-16 13:00:00'),
  ('2016-05-16 14:00:00'),
  ('2016-05-16 15:00:00'),
  ('2016-05-16 16:00:00'),
  ('2016-05-16 17:00:00'),
  ('2016-05-17 13:00:00'),
  ('2016-05-17 14:00:00'),
  ('2016-05-17 15:00:00'),
  ('2016-05-17 16:00:00'),
  ('2016-05-17 17:00:00'),
  ('2016-05-18 13:00:00'),
  ('2016-05-18 14:00:00'),
  ('2016-05-18 15:00:00'),
  ('2016-05-18 16:00:00'),
  ('2016-05-18 17:00:00'),
  ('2016-05-19 13:00:00'),
  ('2016-05-19 14:00:00'),
  ('2016-05-19 15:00:00'),
  ('2016-05-19 16:00:00'),
  ('2016-05-19 17:00:00');

在变量“date”中创建日期之后。我想将伴随的地点插入到另一个名为“地点”的变量中,在那个特定时间去哪里。像这样

INSERT INTO schedule (place)
  VALUES
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A'),
  ('Room A');

但是我需要确保条目匹配,以便“日期”中的第三个条目与“地点”中的第三个条目匹配。我正在寻找解决方案。如果你有比这个例子更好的整体解决方案,请告诉我:)

最佳答案

INSERT INTO schedule (place, date)
VALUES   ('Room A','2016-05-16 13:00:00')

关于mysql - 从特定日期插入 SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36834990/

相关文章:

MySQL 简单选择 - 15 秒执行时间 - 700 万行

php - 有什么方法可以使 MySql 数据库成为 "update itself"吗?

sql - 如何撤销PostgreSQL中特定字段的权限

sql - 每天多次输入,转换为每日和每天的平均值

mysql - 从表中获取最新数据,然后进行求和

php - SQL多对多选择查询

php - MySQL 1 个表、1 个选择、多个Where

java - 我的 ResultSet 正在返回值,但它没有将值存储到字符串,为什么?

mysql - 按一年中的月份获取特定行的排名

php - 是否可以将 php 代码插入 ' header("Location : example. php") ' 命令?