quotes in sql query
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
精彩评论