未知列错误

时间:2012-05-01 20:05:17

标签: php sql

我检查了所有内容,但鉴于我使用PHP不到1个月,我似乎无法理解这一点。每当我使用这个$ sql查询时,它都会给我错误:

//$startrow is variable
$startrow = 0;

$sql = "SELECT `accounts.full_name`, `image.name` FROM `accounts` LEFT JOIN 
`image` ON `accounts.person_id` = `image.person_id` WHERE 
`accounts.image_set` = '$yes' and `accounts.full_name` LIKE '%$q%' 
LIMIT $startrow, 15";

1 个答案:

答案 0 :(得分:2)

您没有名为image的表格。您的表名为face_shot

此外,你的反引号必须包围名称的每个部分(不包括点)。或者你可以完全省略反引号,但reserved words除外。

SELECT `accounts`.`full_name`, `image`.`name`
FROM `accounts`
LEFT JOIN `image` ON `accounts`.`person_id` = `image`.`person_id`
WHERE `accounts`.`image_set` = '$yes'
AND `accounts`.`full_name` LIKE '%$q%' 
LIMIT $startrow, 15