gpt4 book ai didi

mysql - 如何 'Create a table based on a query and delete from first 3 characters to the right'

转载 作者:行者123 更新时间:2023-11-29 06:32:25 25 4
gpt4 key购买 nike

我有一个简单的查询:

select pcode, description from outerb where pcode like '123%'

这是一个 fiddle 链接,向您展示我到达的位置:

https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=bf44b07918374985074084552e7b7005

如何根据上面的查询创建一个新表,但删除第三个字符右侧的所有字符?

这是我的预期输出

pcode   description 
123 TEST
123 TEST

最佳答案

我认为您需要 left() 函数:

select left(pcode, 3) as pcode, description, size
from table1;

关于mysql - 如何 'Create a table based on a query and delete from first 3 characters to the right',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55575316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com