我有一个名为accession
的表:
account_number || access_number
201 || 10091
201 || 10092
202 || 10099
202 || 10100
202 || 10101
202 || 10102
如何使用desc
删除1值?例如,如果我想删除值:account_number
202和access_number
10102,我有这样的查询:
$account_number = $_GET['account_number'];
$delvalue = "delete * from accession where account_number='$account_number'";
mysql_query($delvalue) or die('Error Deleting');
但删除了特定帐号的所有值。 (当然会发生) 你能让我理解一些想法吗?谢谢..
答案 0 :(得分:1)
使用max
:
delete * from accession
where account_number='$account_number'
and access_number=(select max(access_number) from accession where account_number='$account_number')
答案 1 :(得分:1)
如果已定义唯一的自动增量ID列
,则可以使用此查询delete from accession
where account_number='$account_number'
order by (id) DESC limit 1