使用另一个表

时间:2018-06-08 13:01:13

标签: mysql

后视力是20-20,现在我付出了代价。当我第一次设置它时,不需要这些信息,但现在它是我回溯跟踪的。

  • 数据库中的2个表(网站[id,site],visitNotes [site])
  • sites.site填充了visitNotes.site
  • 现在他们想要一个在visitNotes表上的上个月运行警报测试的网站列表,但由于没有录制,因此无法确定哪些网站没有被检查< / LI>

我做了什么

  • 添加了一列visitNotes.siteid

我想做什么

  • 让数据库使用sites.id信息填充visitNotes.siteid列
  • 所以它应该看看visitNotes.site - &gt;匹配sites.site - &gt;获取corrosponding sites.id - &gt;将其放入visitNotes.siteid

网站表[id,site]

&#34; 1&#34; &#34; Lawton Acres&#34;

&#34; 2&#34; &#34; AMBLE&#34;

&#34; 3&#34; &#34; ASHWOOD&#34;

&#34; 4&#34; &#34; BACHMAN&#34;

&#34; 5&#34; &#34;贝内特&#34;

&#34; 6&#34; &#34;桦木&#34;

visitNotes表[id,timestamp,uniqueid,date,siteid (我要填写的内容),site,groupid]

&#34; 7620&#34; &#34; 6/6/2018 08:07:14&#34; &#34; 5b17f0d541017&#34; &#34 5/31/2018年&#34; &#34;&#34; &#34; Stateline West&#34; &#34; 18hprw3&#34;

&#34; 7621&#34; &#34; 6/6/2018 08:08:51&#34; &#34; 5b17f0d541017&#34; &#34 5/31/2018年&#34; &#34;&#34; &#34; Stateline East&#34; &#34; 18Can6&#34;

&#34; 7622&#34; &#34; 6/6/2018 08:12:30&#34; &#34; 5b17f0d541017&#34; &#34 5/30/2018年&#34; &#34;&#34; &#34;椴木&#34; &#34; 18Sp4&#34;

&#34; 7623&#34; &#34; 6/6/2018 08:14:23&#34; &#34; 5b17f0d541017&#34; &#34 5/30/2018年&#34; &#34;&#34; &#34; JMG&#34; &#34; 18C8&#34;

&#34; 7624&#34; &#34; 6/6/2018 08:14:24&#34; &#34; 5b17f0d541017&#34; &#34 5/30/2018年&#34; &#34;&#34; &#34; JMG&#34; &#34; 18C8&#34;

&#34; 7625&#34; &#34; 6/6/2018 08:15:14&#34; &#34; 5b17f0d541017&#34; &#34 5/30/2018年&#34; &#34;&#34; &#34; JMG&#34; &#34; 18C8&#34;

&#34; 7626&#34; &#34; 6/6/2018 08:46:09&#34; &#34; 5b180156327d5&#34; &#34 6/6/2018年&#34; &#34;&#34; &#34; HWY 14&#34; &#34; 18hprw9&#34;

&#34; 7627&#34; &#34; 6/6/2018 10:18:29&#34; &#34; 5b1817189adf5&#34; &#34 6/6/2018年&#34; &#34;&#34; &#34; Powersville&#34; &#34; 18hprw13&#34;

&#34; 7628&#34; &#34; 6/6/2018 13:25:13&#34; &#34; 5b184180dfb16&#34; &#34 6/6/2018年&#34; &#34;&#34; &#34;弗里森1&#34; &#34; 18D12&#34;

&#34; 7629&#34; &#34; 6/6/2018 13:26:55&#34; &#34; 5b184360d2878&#34; &#34 6/6/2018年&#34; &#34;&#34; &#34;弗里森3&#34; &#34;&#34;

&#34; 7630&#34; &#34; 6/6/2018 13:27:53&#34; &#34; 5b184393919e7&#34; &#34 6/6/2018年&#34; &#34;&#34; &#34;欧文&#34; &#34;&#34;

内部加入?我尝试过很多不同的东西,但似乎都没有用。有人可以帮我弄明白怎么做吗?谢谢!

0 个答案:

没有答案