K
K
kolomat2020-09-11 15:57:02
PHP
kolomat, 2020-09-11 15:57:02

How to get the value up to a specific character?

Good afternoon, please advise me on this issue. There is a part of the query
LEFT JOIN main_color c ON m.color = c.color_en
But the problem is that for example in the color column the value can be Yelow / White, and in the color_en table it will be exclusively Yellow, respectively, the query does not find such a value. Is it possible to somehow form a request so that everything in m.color would be cut off before / and then compared with c.color_en?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Vodakov, 2020-09-11
@WaterSmith

LEFT JOIN main_color c ON m.color LIKE '%'+c.color_en+'%'

Finds both Yelow/White and White/Yelow and even Yelowpage (assuming c.color_en = Yelow)
what would cut everything in m.color up to / and then compare it with c.color_en?

If so, then:
LEFT JOIN main_color c ON m.color LIKE '%/'+c.color_en

In this case, it will only find White/Yelow
AND not find WhiteYelow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question