'Is there a way to match patterns from one column to other one?

I want to use club position and check if preferred_position contain the string then return True/False value for each row.

Club_position Preferred_position
RM RM/LW
RCB RB
LW RM/LW
CMD RM/RCM
ST ST
ST ST/LW

I used LIKE() but it returned false when it didn't match exactly as an example: ST = ST/LW returned as false I want my output like

  • True

  • False

  • True

  • False

  • True

  • True

    UPDATE FROM "Football" SET desired_position = "Club_Position" LIKE "Preferred_Position";

It did not work.

Data types are text. I also tried changing them to varchar. It didn't work either.



Solution 1:[1]

Turns out you can use concat.

UPDATE "Football"
SET "Desired_Position" = "Preferred_Position" LIKE CONCAT('%', "Club_Position", '%');

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 marc_s