表架构:
Employee (empid, emp_name, age, DOB, designation, doj, basic_salary, salary_amt, medical_allowance, pension, GPFund, TA, House_allowance)
Monthly_salary (id, empid, year, month, total_salary)
查询:
UPDATE `monthly_salary`
SET `total_salary`=`employee`.'salary_amt' -`employee`.'medical_allownces' - `employee`.'pension'
WHERE `employee`.'empid'=`monthly_salary`.'emp_id'
我试图在phpmyadmin中运行此查询,但它没有运行并出错。 员工empid在月薪表中用作外键。
答案 0 :(得分:1)
删除单个qoutes <script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src= "/js/jquery.datagrid.js"></script>
<script type="text/javascript" src="/js/datagrid-filter.js"></script>
<script type="text/javascript" src= "/js/datagrid-bufferview.js"></script>
<form id="MyUpload" method="post" name="MyUpload"
enctype="multipart/form-data" action="<portlet:actionURL/>">
<!--some code -->
<table>
<tr>
<td>
<div align="right">Name</div>
</td>
<td>
<input type="text" name="name" id="name"/>
</td>
<td>
<div align="right" width="180px">Branch</div>
</td>
<td>
<input type="text" name="branch" id="branch"/>
</td>
<td>
<div align="right" width="180px">Order No:</div>
</td>
<td>
<input name="orderNo" id="orderNo" type="text"/>
</td>
</tr>
</table>
<table>
<tr>
<td align="right" colspan="2">
<a id="addId" onclick="HandleBrowseClick();">Add</a>
</td>
</tr>
<table>
<table>
<div>
<div style="margin: 10px 0 0 0; border-bottom: none;" class="gridTbl">
<div class="easyui-panel" title="Upload details">
<table id="dg" class="tt" style="width: 980px;"
data-options="
singleSelect:true,
rownumbers:true,
reload:true,
pagination:true,
view:bufferview,
pageSize:10
">
<thead>
<tr>
<th data-options="field:'name',width:100">Name </th>
<th data-options="field:'branch',width:100">Branch</th>
<th data-options="field:'orderNo',width:100">Order No</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</tr>
</table>
</form>
function HandleBrowseClick() {
var name = $("#name").val();
var branch= $('#branch').val();
var orderNo = $('#orderNo').val();
$('#dg').datagrid('appendRow', {
name : name,
branch : branch,
orderNo : orderNo
});
}
应该像这样讨厌
'
我给表别名,让它更容易阅读。
答案 1 :(得分:0)
您的查询中未使用加入更新。
UPDATE monthly_salary a
JOIN employee b ON b.empid = a.emp_id
SET a.total_salary=b.salary_amt - b.medical_allownces - b.pension;