Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002
    Posts
    183

    A little MYsql help.

    I'm getting an error running a database command.

    The command I am running is
    Code:
    select * from raidcal where repeat like 'Saturday'
    There is an entry in database where repeat does in fact equal Saturday. However when I run that command I get the following error.

    Code:
    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 'like 'Saturday'' at line 1
    I can run the command on any other field in the table and return results.

    Code:
    Field
    repeat 
    
    Type
    enum('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','null')
     
    Null
    YES  
    
    default
    null

    Any help would be appreciated.

  2. #2
    Join Date
    Mar 2004
    Posts
    1,301
    repeat is a reserved word for mysql.
    Put the word in backticks will resolve the error:
    select * from raidcal where `repeat` like 'Saturday'

    also, why do you decide to use "LIKE" instead of `repeat`='Saturday'?

    see list of reserved words here: http://www.htmlite.com/mysql002a.php

  3. #3
    Join Date
    Jul 2002
    Posts
    183
    Quote Originally Posted by orbitz View Post
    repeat is a reserved word for mysql.
    Put the word in backticks will resolve the error:
    select * from raidcal where `repeat` like 'Saturday'

    also, why do you decide to use "LIKE" instead of `repeat`='Saturday'?

    see list of reserved words here: http://www.htmlite.com/mysql002a.php

    Thanks that works perfectly. I also tried to use = however got the same error. Is that a new deal? This was actually on a script that worked fine before, i assume the webhost updated mysql.

  4. #4
    Join Date
    Mar 2004
    Posts
    1,301
    you must've left something out. Normally, I would echo out the sql statement and see what is wrong there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •