image.png
    (1)从字符中第几位取到第几位 :
    select substring (‘image_create_date’ from 1 for 10 )
    这个是 从这个image_create_date 中第一位取到第10位。
    注:sql中用1代表第一位,编程语言用0代表第一位。
    (2)从表字段中取第几位取到第几位 :
    select from bi.public.vehicle_identification_info_new
    where substring(image_create_date,from ‘………$’ ) = ‘2021-12-27’ limit 10
    去掉字段上的引号就可以表示取表字段了
    (3)还可以用逗号代替 from和for
    select
    from bi.public.vehicle_identification_info_new
    where substring(image_create_date,1,10 ) = ‘2021-12-27’ limit 10
    (4)用…..$表示取最后的前几位
    select from bi.public.vehicle_identification_info_new
    where substring(image_create_date,from ‘………$’ ) = ‘2021-12-27’ limit 10
    (5)按/匹配
    select substring(image_url,’//.
    /‘) from bi.public.vehicle_identification_info_new limit 10

    substring(_hoodie_commit_time ,9,2) 从第9位开始截取2位

    2021-12-30 截取字符串 - 图2