我创建了一个主表:
$enterVals = [7,3,15,11];
for ($i = 0; $i < count($enterVals);$i++) {
$tagsWHERE[] = "id_tag=".intval($enterVals[$i]);
}
$sql->("SELECT ID_group,ID
FROM sys_tags_groups
WHERE ".implode(" OR ",$tagsWHERE)."
GROUP BY ID_group,ID
HAVING SUM(type = 1) AND SUM(type = 0)")
$result = [];
$enterVals = [6,2,15,11];
$result = [{"ID_group":3123,"ID":0},{"ID_group":5142,"ID":0}];
当我得到一个新表,其中只包含名称和电话,我将其恢复并添加到我的数据库中。
现在我想将$scope.userArray = [];
$scope.userdata = $localStorage.data;
$scope.addItem = function(user) {
$scope.userArray.push(user);
$scope.user = {};
$localStorage.data = $scope.userArray;
$scope.userdata = $localStorage.data;
}
添加到 CREATE TABLE main_data
(
id SERIAL NOT NULL,
name character varying(249),
telephone character varying(248)
)
,这样当backup_date
表添加到backup_date
时,它会自动继续main_data
的序列}。我怎么能这样做?
注意经过大量搜索,我只能得到这个解决方案;
backup_date
因为main_table
中有大量数据我无法使用它。
答案 0 :(得分:1)
如果我找对你,你所需要的只是:
insert into main_data (name,telephone) select name,telephone from backup_date
答案 1 :(得分:-1)
嗨哈桑 -
如果您的ID列是自动递增的,那么只需要您的代码 -
insert into main_data (name,telephone) select name,telephone from backup_date where [your condition]
如果您的ID列未自动递增,则首先将其设置为自动递增,然后执行上述查询。谢谢:))