我有两张桌子
<input type='number' min='.01' ng-model='threshold' />
我想要做的是根据日期将table2的所有新条目添加到table1中。我的想法是这样的
table1
+--------+-----+------+
| DATE | VAR| VAL|
+--------+-----+------+
|20160101|VAR_1| 0.4|
|20160101|VAR_2| 0.1|
|20160102|VAR_1| 0.6|
|20160102|VAR_2| 0.1|
|20160103|VAR_1| 0.5|
|20160103|VAR_2| 0.1|
+--------+-----+------+
table 2
+--------+-----+------+
| DATE | VAR| VAL|
+--------+-----+------+
|20160102|VAR_1| 0.6|
|20160102|VAR_2| 0.1|
|20160103|VAR_1| 0.5|
|20160103|VAR_2| 0.1|
|20160104|VAR_1| 0.3|
|20160104|VAR_2| 0.2|
|20160105|VAR_1| 0.2|
|20160105|VAR_2| 0.6|
|20160106|VAR_1| 0.3|
|20160106|VAR_2| 0.4|
+--------+-----+------+
但是我收到语法错误。 使用NOT IN可以正常工作......
INSERT INTO table1 SELECT * FROM table2 WHERE date > (SELECT MAX(date) from table1);
非常感谢任何帮助!
答案 0 :(得分:1)
这是尝试这种方式,我使用date1而不是date
var durationChartData = [];
var lineChartData = {
labels: ["Jan","Feb", "Mar","Apr","May","Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
datasets: [
{
label: "My Second dataset",
fillColor: "rgba(124,181,236,0.4)",
strokeColor: "rgba(124,181,236,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(151,187,205,1)",
data: [durationChartData[0],durationChartData[1],durationChartData[2],durationChartData[3],durationChartData[4],durationChartData[5],durationChartData[6],durationChartData[7],durationChartData[8],durationChartData[9],durationChartData[10],durationChartData[11]]
}
]
};
window.onload = function(){
$.ajax({
url: '/rest/analytical/home/viewed/line',
type: 'GET',
dataType: 'json',
success: function (data) {
dataLength = (data + '').length;
for(var i=0; i<dataLength; i++){
durationChartData[i] = data.ret[i].all;
}
},
error: function (data) {
console.log('duration Chart Data: ' + data);
}
});
var linegraph = document.getElementById("linegraph");
var bargraph = document.getElementById("bargraph");
if(linegraph !== null){
var ctx = linegraph.getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %> min",
responsive: true
});
};