开发者

quotes in sql query

开发者_JAVA百科

how can you add quotes in a sql query if the field names includes "-" or other charactors or if the field has a reserved name like "type" or others

SELECT `enclosure.id`, `enclosure.time`, `enclosure.note` 
FROM tbl.enclosure LEFT JOIN tbl.book ON book.enc_id=enclosure.id 
WHERE `book.book_id`='277' ORDER BY enclosure.time DESC, enc_id_ DESC 

error

#1054 - Unknown column 'enclosure.id' in 'field list'


I'm not sure if I got you correct, but I think you should replace

`book.bookid`

with

`book`.`bookid`

.


you have something wrong in query..it must be like below ( you did not set alias for table )

SELECT `enclosure`.id`, `enclosure`.time`, `enclosure`.note` 
FROM tbl_enclosure  enclosure 
LEFT JOIN tbl_book book ON `book`.`enc_id`=`enclosure`.`id` 
WHERE `book`.book_id`='277' 
ORDER BY `enclosure`.`time` DESC, `enclosure`.`enc_id` DESC 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜