简体   繁体   中英

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

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!.

在子查询中,您需要使用表名称t_publications.language来限定language

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM