在mysql中,有个客户资料表,有个字段标记着该条记录的状态,1--为正在处理,0-为未处理,2-为已经处理。客户端不断的使用
select * from customer where issused='0' 来显示客户资料,这样存在一个问题就是:一个客户资料有可能同时在两个客户端同时显示了。有什么办法可以避免?多谢各位。
select * from customer where issused='0' 来显示客户资料,这样存在一个问题就是:一个客户资料有可能同时在两个客户端同时显示了。有什么办法可以避免?多谢各位。
解决方案 »
- 怎么统计某个用户提交过多少天记录?
- 我想问下为什么我的mysql front不能上到Mysql服务器连接127.0.0.1
- 还是上次那个问题(ACMAIN_CHM wwwwA, wwwwb等请进)
- 求解:怎么样将即时数据保存到数据库
- 请高手分析下这个SQL语句,关于group by 和 sum的
- sql查询语句合并成一条记录
- left join中的问题 拜求!在线等待
- 关系代数怎么表示分组排序
- select substring(sendtime,1,8) ,count(*) from (select sendtime c from hasms_mo) group by substring(sendtime,1,8) ;为什么不能做?
- 关于字段的问题
- 小企业局域网 做一个客户资料的软件
- 咨询一条MYSQL语句的写法
DELIMITER $$DROP PROCEDURE IF EXISTS `crm`.`SelectCustomerData`$$CREATE DEFINER=`root`@`localhost` PROCEDURE `SelectCustomerData`(Workid char(20))
begin
-- ---------------------------------
declare SQLCondition varchar(100);
declare Cust_id int;
set SQLCondition=concat(" ifdealing=0 and staffno='' and workid='",Workid,"'");
-- 这里条件的意思是:查询属于workid组的未处理(ifdealing=0)并且工号字段为空的数据
-- 顺序取记录SET TRANSACTION ISOLATION LEVEL SERIALIZABLE ; --设置事务为串读
START TRANSACTION ; --开始一个事物select id into Cust_id from hr_customerdata where ifdealing=0 and staffno='' and workid=Workid order by id limit 1 for update;
if not isnull(Cust_id) then --如果能够取到数据,则更新状态,并把数据取出来后由存储过程返回给客户端程序。
update hr_customerdata set ifdealing=1 where id= Cust_id ;
set @sql=concat("SELECT * from hr_customerdata where id=",Cust_id);
PREPARE stmt1 FROM @sql ;
EXECUTE stmt1 ;
DEALLOCATE PREPARE stmt1;
Set@sql=NULL;
end if;
commit ;
end$$DELIMITER $$;
中不起作用。哪位知道是什么原因,或者如何做?多谢
对了,我发现我的Workid 变量在select id into Cust_id from hr_customerdata where ifdealing=0 and staffno='' and workid=Workid order by id limit 1 for update;
中不起作用。哪位知道是什么原因,或者如何做?多谢 --------------------
知道是什么原因啦,因为变量和字段名一样,所以会造成这样。