我想从表单和另一个表中插入数据 $array = Import-Csv .\2K8R2Patches.csv -header Patchname
$patches = @()
foreach ($patch in $array) {
$PatchID = $patch -split('-') | Select-String -Pattern "KB"
$HotFix = Get-HotFix -Id $PatchID -ErrorAction 0;
if ($HotFix)
{
$object = New-Object -TypeName psobject -Property @{
HotFixID = $HotFix.HotFixID
Description = $HotFix.Description
InstalledOn = $HotFix.InstalledOn
}
$patches += $object
}
Else
{
$nopatch = New-Object -TypeName psobject -Property @{
HotFixID = $PatchID
InstalledOn = "Not Installed"
Description = "Not Installed"
}
$patches += $nopatch
}
}
$patches |select HotFixID, Description, InstalledOn| Out-File mypath\patch.txt
在同一个表中inv_id = "'.$inv.'"
"history"
是从表单输入的数据)(抱歉我的英文不好)
其实是我的查询:
($inv
如何结合两个查询?现在,此查询将数据插入两个不同的行。
历史表:
答案 0 :(得分:1)
您可以使用子查询生成condition
字段的值:
INSERT INTO
`istoric`
SET
`id_user` = '".$user."',
`id_equipment` = '".$nr_inv."',
`start` = '".$startdate."',
`end` = '".$enddate."',
`comment` = '".$comment."',
`condition` = (
SELECT
`status`
FROM
`echipament`
WHERE
`nr_inventar` = '".$nr_inv."'
);
此外,根据您对查询进行格式化的方式,您应该为查询使用预准备语句,而不是将变量直接注入查询