我正在尝试以下MySQL查询来获取一些数据:
SELECT m.*, t.* FROM memebers as m, telephone as t INNER JOIN memeberFunctions as mf ON m.id = mf.memeber INNER JOIN mitgliedTelephone as mt ON m.id = mt.memeber WHERE mf.function = 32
但是我总是得到以下错误:
#1054 - Unknown column 'm.id' in 'on clause'
该列确实存在,并且查询仅适用于一个表(例如,当我卸下电话时)
有人知道我做错了吗?
似乎您的要求是联接members表,但您正在联接telephone表。只是改变他们的顺序。
members
telephone
SELECT `m`.*, `t`.* FROM `memebers` AS `m` JOIN `telephone` AS `t` JOIN `memeberFunctions` AS `mf` ON `m`.`id` = `mf`.`memeber` AND `mf`.`function` = 32 JOIN `mitgliedTelephone` AS `mt` ON `m`.`id` = `mt`.`memeber`;
希望这对您有所帮助。谢谢!!