我无法让我的sql根据包含数字的“订单”列来提取照片。以下工作正常,但它似乎是基于“cms_uploads”中的“num”列拉入照片。
$photoSql = "SELECT * FROM cms_uploads WHERE ('tableName'='residential_master_rental_availabilities' AND 'recordNum' = '".$rent['num']."' AND 'fieldname' = 'image') LIMIT 1";
此查询不返回任何内容:
$photoSql = "SELECT * FROM cms_uploads WHERE ('tableName'='residential_master_rental_availabilities' AND 'recordNum' = '".$rent['num']."' AND 'fieldname' = 'image') ORDER BY 'order' LIMIT 1";
答案 0 :(得分:3)
order
是reserved word。
order by
需要反引号而不是单引号。你是按常数排序 - 即什么也不做:
ORDER BY `order`
为了帮助编写代码,仅使用单引号作为字符串常量和日期。