Postgresql: Matching Patterns between Two Columns

后端 未结 3 889
名媛妹妹
名媛妹妹 2021-01-20 00:27

I have two columns say Main and Sub. (they can be of same table or not).

Main is varchar of length 20 and Sub is

3条回答
  •  有刺的猬
    2021-01-20 00:49

    Try

    SELECT t1.* from "Main Table" AS t1, "SubTable" AS t2
     WHERE t2.SubId=1043
       AND substr(t1.MainColumn, 13, 8) LIKE "%" || CAST(t2.SubColumn as text);
    

提交回复
热议问题