小编Hao*_*aru的帖子

MySQL子串在两个字符串之间

我需要一只手来解决我的列字段的问题.我需要在这两个不同的"模式"字符串之间提取字符串,例如:

[... string] contract = 1234567890123350566076070666已发出= [string ...]

我想在'contract ='和'issued ='之间提取字符串

目前我正在使用

SELECT substring(substring_index(licence_key,'contract=',-1),1,40) FROM table
Run Code Online (Sandbox Code Playgroud)

问题是它之间的这个字符串不总是有40个字符,所以它不是固定的长度,因此它之前和之后的数据.这是一个不稳定的数据.

你知道我怎么能处理吗?

mysql string indexing substring function

19
推荐指数
1
解决办法
2万
查看次数

是否可以在没有表的select语句中创建许多行?

我想知道是否可以在此select语句中生成多于一行:

select
      floor(1+(rand()*(1+100-1))) as B1
     ,floor(1+(rand()*(1+100-1))) as B2
     ,floor(1+(rand()*(1+100-1))) as B3
     ,floor(1+(rand()*(1+100-1))) as B4
     ,floor(1+(rand()*(1+100-1))) as B5
     ,floor(1+(rand()*(1+100-1))) as B6 ;
Run Code Online (Sandbox Code Playgroud)

而不是这(单行)

    B1  B2  B3  B4  B5  B6
    -- --   --  --  --  --
    48  35  30  44  31  24
Run Code Online (Sandbox Code Playgroud)

我想看到这个(或者在循环中或者像我想要的那样多行)

B1  B2  B3  B4  B5  B6
-- --   --  --  --  --
48  35  30  44  31  24
24  2   34  15  22  15
11  7   2   36  27  26
49  19  44  17  49  47
39  4   48 …
Run Code Online (Sandbox Code Playgroud)

mysql sql select

2
推荐指数
1
解决办法
1082
查看次数

标签 统计

mysql ×2

function ×1

indexing ×1

select ×1

sql ×1

string ×1

substring ×1