Home > front end >  Is there a way to match patterns from one column to other one?
Is there a way to match patterns from one column to other one?

Time:05-09

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

Club_position Preffered_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 "Preffered_Position";

Not worked.

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

CodePudding user response:

Turns out you can use concat.

UPDATE "Football"
SET "Desired_Position" = "Preffered_Position" LIKE concat('%', "Club_Position", '%');
  • Related