SQL语句删除字段内字符串的某些字符(xxx,xxx,xxx,xxx)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_44152538/article/details/88823541

最近处理数据库比较频繁,看了很多关于sql的函数。

感触很深,能在代码中解决的基本上都有sql函数,sql语句去解决。虽然这样会增加数据库负担。

还是以学习为主。 

今天就学习了一条,可以在字段内删除相应内容的sql函数。

当前字段里的内容: xxxx,yyyy,zzzz,  数据库里存的是VERCHAR  以文本类型存的。

现在需要: 删除‘yyyy’

 

sql语句:

UPDATE  表名 SET 字段名 = REPLACE(字名,"yyyy,"," ") WHERE +判断条件;

 

ps:如果大家存表时是通过 逗号分割的想要删除的后面记得加上 ,

 

以后还是要多看看sql函数。还有很多需要学习的。。。

展开阅读全文

Xxx

10-20

C# 仿QQ截图程序 winformrnusing System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Text;rnusing System.Windows.Forms;rnrnnamespace Clientrnrn public partial class Catch : Formrn rn public Catch()rn rn InitializeComponent();rn rnrn 用户变量#region 用户变量rn private Point DownPoint = Point.Empty;//记录鼠标按下坐标,用来确定绘图起点rn private bool CatchFinished = false;//用来表示是否截图完成rn private bool CatchStart = false;//表示截图开始rn private Bitmap originBmp;//用来保存原始图像rn private Rectangle CatchRect;//用来保存截图的矩形rn #endregionrnrn //窗体初始化操作rn private void Catch_Load(object sender, EventArgs e)rn rn this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);rn this.UpdateStyles();rn //以上两句是为了设置控件样式为双缓冲,这可以有效减少图片闪烁的问题,关于这个大家可以自己去搜索下rn originBmp = new Bitmap(this.BackgroundImage);//BackgroundImage为全屏图片,我们另用变量来保存全屏图片rn rnrn //鼠标右键点击结束截图rn private void Catch_MouseClick(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Right)rn rn this.DialogResult = DialogResult.OK;rn this.Close();rn rn rnrn //鼠标左键按下时动作rn private void Catch_MouseDown(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left)rn rn if (!CatchStart)rn //如果捕捉没有开始rn CatchStart = true;rn DownPoint = new Point(e.X, e.Y);//保存鼠标按下坐标rn rn rn rnrn private void Catch_MouseMove(object sender, MouseEventArgs e)rn rn if (CatchStart)rn //如果捕捉开始rn Bitmap destBmp = (Bitmap)originBmp.Clone();//新建一个图片对象,并让它与原始图片相同rn Point newPoint = new Point(DownPoint.X, DownPoint.Y);//获取鼠标的坐标rn Graphics g = Graphics.FromImage(destBmp);//在刚才新建的图片上新建一个画板rn Pen p = new Pen(Color.Blue,1);rn int width = Math.Abs(e.X - DownPoint.X), height = Math.Abs(e.Y - DownPoint.Y);//获取矩形的长和宽rn if (e.X < DownPoint.X)rn rn newPoint.X = e.X;rn rn if (e.Y < DownPoint.Y)rn rn newPoint.Y = e.Y;rn rn CatchRect = new Rectangle(newPoint,new Size(width,height));//保存矩形rn g.DrawRectangle(p,CatchRect);//将矩形画在这个画板上rn g.Dispose();//释放目前的这个画板rn p.Dispose();rn Graphics g1 = this.CreateGraphics();//重新新建一个Graphics类rn //如果之前那个画板不释放,而直接g=this.CreateGraphics()这样的话无法释放掉第一次创建的g,因为只是把地址转到新的g了.如同string一样rn g1 = this.CreateGraphics();//在整个全屏窗体上新建画板rn g1.DrawImage(destBmp,new Point(0,0));//将刚才所画的图片画到这个窗体上rn //这个也可以属于二次缓冲技术,如果直接将矩形画在窗体上,会造成图片抖动并且会有无数个矩形.rn g1.Dispose();rn destBmp.Dispose();//要及时释放,不然内存将会被大量消耗rn rn rn rnrn private void Catch_MouseUp(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left)rn rn if (CatchStart)rn rn CatchStart = false;rn CatchFinished = true;rn rn rn rn rnrn //鼠标双击事件,如果鼠标位于矩形内,则将矩形内的图片保存到剪贴板中rn private void Catch_MouseDoubleClick(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left&&CatchFinished)rn rn if (CatchRect.Contains(new Point(e.X, e.Y)))rn rn Bitmap CatchedBmp = new Bitmap(CatchRect.Width, CatchRect.Height);//新建一个于矩形等大的空白图片rn Graphics g = Graphics.FromImage(CatchedBmp);rn g.DrawImage(originBmp, new Rectangle(0, 0, CatchRect.Width, CatchRect.Height), CatchRect, GraphicsUnit.Pixel);rn //把orginBmp中的指定部分按照指定大小画在画板上rn Clipboard.SetImage(CatchedBmp);//将图片保存到剪贴板rn g.Dispose();rn CatchFinished = false;rn this.BackgroundImage = originBmp;rn CatchedBmp.Dispose();rn this.DialogResult = DialogResult.OK;rn this.Close();rn rn rn rn rnrn  C.创建了Catch窗体后,我们在截图按钮(位于聊天窗体上)上加入以下事件:rn private void bCatch_Click(object sender, EventArgs e)rn rnrn if (bCatch_HideCurrent.Checked)rn rn this.Hide();//隐藏当前窗体rn Thread.Sleep(50);//让线程睡眠一段时间,窗体消失需要一点时间rn Catch CatchForm = new Catch();rn Bitmap CatchBmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);//新建一个和屏幕大小相同的图片 rn Graphics g = Graphics.FromImage(CatchBmp);rn g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));//保存全屏图片rn CatchForm.BackgroundImage = CatchBmp;//将Catch窗体的背景设为全屏时的图片rn if (CatchForm.ShowDialog() == DialogResult.OK)rn //如果Catch窗体结束,就将剪贴板中的图片放到信息发送框中rn IDataObject iData = Clipboard.GetDataObject();rn DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);rn if (iData.GetDataPresent(DataFormats.Bitmap))rn rn richtextbox1.Paste(myFormat);rn Clipboard.Clear();//清除剪贴板中的对象rn rn this.Show();//重新显示窗体rn rn rnrn rn 论坛

spring cglib报错 xxx cannot be cast to xxx

01-18

[b][size=18px]1, 想使用 ehcache + spring jdbc 实现查询结果缓存,现在功能都实现了,但是使用时报错[/size]:[/b]rnrn[code=java]rnjava.lang.ClassCastException: com.hbzx.bean.ShopViewCountBean cannot be cast to java.util.Listrn at com.hbzx.dao.ShopViewCountDao$$EnhancerBySpringCGLIB$$1c70ff76.queryAll()rn at com.hbzx.service.ShopViewCountService.fillHistory(ShopViewCountService.java:143)rn at com.hbzx.service.ShopViewCountService.query(ShopViewCountService.java:46)rn at com.hbzx.controller.UserCommissionController.getMyShopLog(UserCommissionController.java:45)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:483)rn at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)rn at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)rn at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)rn at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:743)rn at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:672)rn at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:82)rn at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)rn at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)rn at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)rn at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)rn at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:202)rn at net.bull.javamelody.MonitoringFilter.doFilter(MonitoringFilter.java:180)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)rn at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)rn at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537)rn at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1085)rn at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)rn at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)rn at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1556)rn at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1513)rn at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)rn at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)rn at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)rn at java.lang.Thread.run(Thread.java:745)rn[/code]rnrn 论坛

高手帮我看看 Insert Into XXX Select XXX ....

07-26

Insert Into XXXX(XX, XX, XX, XX) rnSelect XX, XX, XX, XX From XXX rnWhere x = xrnAnd X = Xrnrnrn这样的SQL我在PL/SQL中执行是可以成功的,不知为什么到我的程序里就执行不成功呢?!??rnrn我用的是ibatis....rnrn我测试的时候报错如下:rnrnException in thread "main" java.lang.NullPointerExceptionrn at com.suoyasoft.boh.ims.dao.impl.RscDcScheduleDAOImpl.copyRscDcSchedule(RscDcScheduleDAOImpl.java:45)rn at com.suoyasoft.boh.ims.service.IMSService.copyRscDcSchedule(IMSService.java:137)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)rn at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)rn at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)rn at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)rn at $Proxy0.copyRscDcSchedule(Unknown Source)rn at com.suoyasoft.boh.ims.test.ImsTest.copy(ImsTest.java:143)rn at com.suoyasoft.boh.ims.test.ImsTest.main(ImsTest.java:38) 论坛

没有更多推荐了,返回首页