0

I get this error at this code:

 SELECT "LastUpdate" ;
 FROM "xx_yy";

Is LastUpdate a reserved word ?

I tried to change " " to `` or delete them, I don't really know the perfect combination to make it work. I'm beginner in this.

Söraka
  • 53
  • 1
  • 5
  • I've got to remember that duplicate question for the future. – John Conde May 30 '14 at 18:41
  • @user3691628 The question I linked frames this in context of PHP. Just be sure you are removing the outer quotes that make the answer examples into PHP strings if you're working directly in a MySQL client. – Michael Berkowski May 30 '14 at 18:44

4 Answers4

3

Get rid of the quotes around your column identifier and tablename. That makes them strings instead of identifiers. Either use ticks or nothing at all. Also, ditch the semi-colon after the first line as it is terminating your query before it reaches the FROM clause.

SELECT `LastUpdate` 
 FROM `xx_yy`;

or

SELECT LastUpdate 
 FROM xx_yy;
John Conde
  • 217,595
  • 99
  • 455
  • 496
1

Remove the first semicolon.

SELECT FOO FROM BAR

The above is all one statement.

clarkitect
  • 1,720
  • 14
  • 23
1

A semicolon (;) signifies the end of a statement. So you actually have two separate, distinct statements:

  1. SELECT "LastUpdate"
  2. FROM xx_yy

The second statement is not valid, which is why you are seeing the error.

Solution: Remove the semicolon at the end of the first line:

SELECT "LastUpdate"
FROM "xx_yy";

Also note if the ANSI_QUOTES sqlmode is not enabled, MySQL treats double-quotes as string literals (the same as single quotes). You may need to change these to the MySQL-specific backtick, or remove them entirely:

SELECT `LastUpdate`
FROM `xx_yy`;
lc.
  • 113,939
  • 20
  • 158
  • 187
  • I tried and the code work. But what you think is this error about ? Sql query failed due to [Unknown column 'LastUpdate' in 'field list'], Query: [SELECT LastUpdate FROM xx_yy;] – Söraka May 30 '14 at 18:42
  • It could have to do with quoting. In MySQL, if the table was created with quoted column names that are not all-caps, you will have to always select with quoted column and it is CASE-SENSITIVE. – lc. May 30 '14 at 18:44
  • I don't know, the names are same the same, I really have no ideea how to solve it. I'll be so thankfull if you can help me. I'd like to know if you need more informations, I can send you a PM with some screenshots. – Söraka May 30 '14 at 18:50
0

Most likely your query should look like

SELECT "LastUpdate" FROM "xx_yy";

; is marking an end of a query.

frlan
  • 6,950
  • 3
  • 31
  • 72