手边有一个系统,他的db的一个字段名是: update time  在select语句中,我想单独查看这个字段的信息,请教下这个字段名前后要加什么符号?

解决方案 »

  1.   

    加上反引号就行了。 `update time`mysql> desc t7;
    +-------------+----------+------+-----+---------+-------+
    | Field       | Type     | Null | Key | Default | Extra |
    +-------------+----------+------+-----+---------+-------+
    | id          | int(11)  | NO   | PRI | NULL    |       |
    | update time | datetime | YES  |     | NULL    |       |
    +-------------+----------+------+-----+---------+-------+
    2 rows in set (0.02 sec)mysql> select *
        -> from t7
        -> where `update time` is null;
    Empty set (0.00 sec)mysql>
      

  2.   

    用accent grave (`)而不是'或"把这个field括起来. see also:
    http://forums.invisionpower.com/topic/195121-mysql-select-column-containing-space/多用google哈。
    http://www.google.com/search?hl=en&newwindow=1&q=mysql+table+name+space