开发者

MySQL use a field as variable for the where statement (with like)

开发者 https://www.devze.com 2023-02-17 06:46 出处:网络
First of all, apologies for the title of this question, but i couldn\'t come up with anything 开发者_开发技巧better. So jumping straight into the code, here\'s what im trying to do:

First of all, apologies for the title of this question, but i couldn't come up with anything 开发者_开发技巧better. So jumping straight into the code, here's what im trying to do:

SELECT title,
       content,
       language,
(SELECT t.iso_code FROM t_language_codes t
 WHERE lower(t.iso_code_name)  like concat('%', language, '%') LIMIT 1) AS    languageMapped
FROM t_publications;

I'm attempting to use the language field with the like of the where statement. Since i'm receiving publications with different languages codes and i'm sort of trying to standardize into the iso format... My question is, how do i make the language field work with the like and '% %' statement? being googleing for a while without luck. Any help most appreciated!.


In the subquery, you need to qualify language with the name of the table: t_publications.language.

0

精彩评论

暂无评论...
验证码 换一张
取 消