知道我的查询有什么问题吗?
irb(main):010:0> dbh.query('SELECT foo FROM bar')
Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"' at line 1
from (irb):10:in `query'
from (irb):10
from /usr/bin/irb1.9:12:in `<main>'
表bar
肯定存在,列foo
也是如此。
dbh也是一个合法的对象:
irb(main):012:0> dbh
=> #<Mysql:0x91149c4>
irb(main):011:0> dbh.methods.grep(/query/)
=> [:query, :real_query, :query_with_result, :query_with_result=]
答案 0 :(得分:0)
粘贴一个真实的查询,也许表名或字段名是mysql中的保留关键字。
尝试使用分隔符:
dbh.query('SELECT `foo` FROM `bar`')