前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >quotename mysql,我如何在mySQL中创建一个QUOTENAME函数

quotename mysql,我如何在mySQL中创建一个QUOTENAME函数

作者头像
全栈程序员站长
发布2022-09-15 11:28:18
1.9K0
发布2022-09-15 11:28:18
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

I would like to create a QUOTENAME() function in mySQL like the one that exists in M$ SQL Server.

This is what it does:

QUOTENAME returns a Unicode string with the delimiters added to make the input string a valid identifier. The QUOTENAME function uses this syntax:

QUOTENAME ( ‘string’ [ , ‘delimiter’ ] )

You pass QUOTENAME a string to be delimited and a one-character string to use as the delimiter. The delimiter can be a square bracket or a single or double quotation mark.

Is this even possible?

解决方案

You could start with something like this – building off of eggyal’s comment

DROP FUNCTION IF EXISTS QUOTENAME;

CREATE FUNCTION QUOTENAME (s varchar(50), d CHAR(1))

RETURNS VARCHAR(52)

RETURN CONCAT (d, REPLACE(s, d, CONCAT(d,d)), d);

And then add your special cases and additional functionality.

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/164261.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档