以下查询会产生一些错误:
$sub = '( SELECT mulitple.* FROM timezoneabbreviation AS mulitple
WHERE single.gmtoffset = mulitple.gmtoffset) AS sametimezone';
$query = "SELECT $sub,single.* FROM timezoneabbreviation AS single
WHERE full_name='".$full_name."' ";
return $this->db->query($query)->row();
我想在同一个表中使用子查询编写一个查询,其中条件主查询生成单行但子查询生成多行。
答案 0 :(得分:0)
只需使用JOIN
即可$query = "SELECT mulitple.*, single.*
FROM timezoneabbreviation AS single
INNER JOIN timezoneabbreviation AS mulitple
ON mulitple.gmtoffset = single.gmtoffset
WHERE single.full_name='".$full_name."'";