我想从我的数据库中获取我的位置city和country数据location。
这是我的代码:
$data = mysql_fetch_array(mysql_query("
SELECT
u.`prename`,
u.`surname`,
DATE_FORMAT(u.`birthday`, '%d. %M') AS bday,
l.`city`,
l.`country`
FROM
`users` AS u
LEFT JOIN `users_location` AS ul ON ul.`uid` = u.`id`
LEFT JOIN `locations` AS l ON l.`id` = ul.`location_id`
WHERE u.`id`='".(int) ($_GET['id'])."'"));
Inusers_location分配了哪个用户有哪个location_id。
(users_location结构:id, uid, location_id)
其中locations是city和country名称。
但是city,country使用我的查询是空的。我猜是因为我的加入声明?