我有两个表:companies
和countries
,我想通过查看list_of_countries
表中的companies
字段来检索国家/地区。
SELECT id, name
FROM countries
WHERE name LIKE CONCAT('%', (SELECT list_of_countries FROM companies WHERE id = 1), '%')
这会返回零结果,并应返回两个值according to this SQLFiddle。
答案 0 :(得分:0)
如果您可以重新格式化list_of_countries
并删除多余的空格。
您可以将此类查询与FIND_IN_SET
函数
http://sqlfiddle.com/#!9/ad5ffd/2
SELECT c.id, c.name
FROM companies comp
LEFT JOIN countries c
ON FIND_IN_SET(c.name, comp.list_of_countries)
WHERE comp.id = 1
答案 1 :(得分:0)
解决了。
$structure = imap_fetchstructure($connection, $msgno);
$encoding = $structure->encoding;
$body = imap_fetchbody ($connection, $msgno, 1);
$body=decodebody($encoding, $body);
echo $body;
function decodebody($encoding, $body)
{
switch ($encoding)
{
# 7BIT
case ENC7BIT:
echo "7BIT<br>";//
return $body;
break;
# 8BIT
case ENC8BIT:
echo "8BIT<br>";//
return quoted_printable_decode(imap_8bit($body));
break;
# BINARY
case ENCBINARY:
echo "BINARY<br>";//
return imap_binary($body);
break;
# BASE64
case ENCBASE64:
echo "BASE64<br>";//
return imap_base64($body);
break;
# QUOTED-PRINTABLE
case ENCQUOTEDPRINTABLE:
echo "QUOTED<br>";//
return quoted_printable_decode($body);
break;
# OTHER
case ENCOTHER:
echo "OTHER<br>";//
return $body;
break;
# UNKNOWN
default:
echo "UNKNOWN<br>";//
return $body;
break;
}
}
答案 2 :(得分:0)
在这种情况下,您应该使用find_in_set
。这是我的例子:
select *
from companies t1
left join countries t2 on find_in_set(t2.name, t1.list_of_countries) > 0
这里fiddle。