大家好,如何在表格中搜索来自获得上次更新交易的同一用户的金额?下面的语句有问题
SELECT `Amount`
from `contributions`
where `MemberName` like "KEL" getLastRecord
ORDER BY id DESC
LIMIT;
SELECT Amount from contributions
where MemberName like '%KEL%'
ORDER BY id DESC LIMIT 1;
您还可以添加%
以充当通配符。
'%Kel%' any string that contains the sequence
'%Kel' any string that ends with that sequence
'Kel%' any string that starts with the sequence
如果您只是想按名称"Kel"进行搜索
SELECT Amount from contributions
where MemberName = 'KEL'
ORDER BY id DESC LIMIT 1;
您不需要为此LIKE
您有一个错误的双引号序列和一个错误的getlastRecord尝试
SELECT Amount
from contributions
where MemberName like "KEL"
ORDER BY id DESC LIMIT 1 ;
为了更好地使用,你可以使用野生字符
SELECT Amount
from contributions
where MemberName like "%KEL%"
ORDER BY id DESC LIMIT 1 ;
否则你应该使用
SELECT Amount
from contributions
where MemberName = "KEL"
ORDER BY id DESC LIMIT 1 ;