3

I have a table (stitch) with one row, like this:

table

All columns are formatted as text.

when I run:

SELECT * FROM stitch WHERE user='liam' I get the expected result of a single row.

But when I run:

SELECT * FROM stitch WHERE group='010000' I get a syntax error. I cannot see what I am doing wrong.

Can anyone help me out?

mickmackusa
  • 43,625
  • 12
  • 83
  • 136
user2351418
  • 381
  • 3
  • 5
  • 13
  • can you share table structure screen short? – Rajiv Ranjan Dec 14 '13 at 02:37
  • 4
    The group seems to be MySQL reserved word, try this : `SELECT * FROM stitch WHERE \`group\`='010000'` – Ta Duy Anh Dec 14 '13 at 02:39
  • or you can share syntax error, after running query by phpmyadmin or sql command prompt. – Rajiv Ranjan Dec 14 '13 at 02:39
  • Taiki was correct. When I run "SELECT * FROM stitch WHERE `group`='010000'" it works. Since group is a command in mysql it was messing things up. Thanks! – user2351418 Dec 14 '13 at 02:42
  • Does this answer your question? [When to use single quotes, double quotes, and backticks in MySQL](https://stackoverflow.com/questions/11321491/when-to-use-single-quotes-double-quotes-and-backticks-in-mysql) – mickmackusa Apr 04 '20 at 01:21

1 Answers1

7

it is because group is a keyword in MySql. So use rather:

SELECT * FROM stitch WHERE `group`='010000'

i.e. group inside backticks(``).

Cholowao
  • 947
  • 12
  • 18
Trying
  • 14,004
  • 9
  • 70
  • 110