我的SQL查询
SELECT
team.id,
team.atitle,
team.etitle,
team.cup_id,
team.logo,
team.modarb,
team.count_id,
team.link AS tlink,
country.atitle AS name,
country.etitle AS ename,
cup.id AS catid,
cup.link,
cup.description,
cup.name AS cupname
FROM cup LEFT JOIN team ON (cup.id IN (". implode(', ', 'team.cup_id') ."))
LEFT JOIN country ON (country.id = team.count_id)
where cup.id='5'
row team.cup_id看起来像这个5,4,3, 需要知道如何在mysql查询中使用implode
答案 0 :(得分:0)
您应该修复数据结构,这样就不会将ID列表存储为字符串。这样做是错误的,错误的,错误的:
万一你无法修复数据结构,你可以这样做:
FROM cup LEFT JOIN
team
ON find_in_set(cup.id, team.cup_id) > 0 LEFT JOIN
country
ON (country.id = team.count_id)
我只提供此作为止损,直到您将数据修复为表格中的SQLish。