一个简单的sql语句,查了一些资料:

1、SQL Server:(不解释)

SELECT PATINDEX('%M_rs%', 'The stars near Mars are far from ours');

SELECT CHARINDEX('Mars', ' The stars near Mars are far from ours');

 

2、mysql如下:

如下:两个表str1 ,str2

str1表

 

id name
1 aa
2 bb
3 ee

 

str2  表

id name
1 a

2

b

 

str2表中 name 匹配str1中的name

   尝试select a.id, a.name from str1 a ,str2 b where a.name like ‘%'+b.name+'%' 报错了!

正确:

select a.id, a.name from str1 a ,str2  b where a.name like concat(b.name, '%')

相关文章:

  • 2021-11-23
  • 2022-01-08
  • 2018-04-08
  • 2021-11-22
  • 2021-11-08
  • 2021-11-22
  • 2021-11-22
  • 2021-12-10
猜你喜欢
  • 2021-12-02
  • 2021-10-24
  • 2018-12-21
  • 2021-11-22
  • 2021-12-02
  • 2021-10-19
相关资源
相似解决方案