我正在尝试写一个query
,在插入2件事之前必须检查 -
以下是我试图写的查询:
insert into auc_bit_history (last_bid_amt,userid,aucid,bit_coin,datemade,updated_at)
select IFNULL(max(1+1),1) as bidamount,6,911,1,'2018-03-07 19:22:48','2018-03-07 19:22:48'
from auc_bit_history
where aucid=911 and userid!=(
select if(count(*)=0,0,userid) as lastbidderId
from auc_bit_history
where aucid=911
order by id
desc limit 0,1)
我的查询的这部分工作正常:
insert into auc_bit_history (last_bid_amt,userid,aucid,bit_coin,datemade,updated_at)
select IFNULL(max(1+1),1) as bidamount,6,911,1,'2018-03-07 19:22:48','2018-03-07 19:22:48'
from auc_bit_history
where aucid=911
但是现在我还想检查最后一个投标人是不是同一个用户:
select if(count(*)=0,0,userid) as lastbidderId
from auc_bit_history where aucid=911
order by id desc
limit 0,1
我需要在不使用left/right join
请帮帮我。