mysql sql

 select concat('OD',date_format(now(),'%Y%m%d'),LPAD(NEXTVAL(date_format(now(),'%Y%m%d')),4,'0'));
 select length('OD201504040000');
 select LOCATE('e','eqwe,rqwe');
 
select left('eqwe,rqwe',2);
select right('left,right',2);
select length('left,right');
select right('left,right',length('left,right')-LOCATE(',','left,right')) ;

 

  set @v_det= '7,2';-- old.v_det; -- 7,2,7,2 [{"GID":"7","NUM":"2"},{"GID":"7","NUM":"2"}]
		WHILE (LOCATE(',', @v_det)>0) do		
		set @v_gid = left( @v_det,LOCATE(',', @v_det )); -- 明细商品id
		set @temp = right( @v_det,(length(@v_det)-LOCATE(',' ,  @v_det))); --  select right('left,right',length('left,right')-LOCATE(',','left,right')) ;
		set @v_count = left( @temp,LOCATE(',', @temp)); -- 明细数量
        set @v_det = right( @temp,(length(@temp)-LOCATE(',' ,  @temp))); 
		
		-- set @v_sql = concat('insert into t_order_item2(qd_id,com_id,snum) values (,', @v_gid,''',''', @v_count,'''');
        set @v_sql = concat(@v_gid );
        insert into t_order_item2 (com_id) values(@v_sql);
		-- prepare stmt from @v_sql;  -- 预处理需要执行的动态SQL,其中stmt是一个变量
		-- EXECUTE stmt;      -- 执行SQL语句
		-- deallocate prepare stmt;     -- 释放掉预处理段
		 END WHILE;

 

你可能感兴趣的:(mysql)