0

Im using google app engine data-store built in eclipse using my model for the table. The id is just the date and time from android.

I can query by a row like this and it does work!

select from Quotes as Quotes ORDER BY votes DESC

I want to get my results back by my entities id however this query does not work

select from Quotes as Quotes ORDER BY Id DESC

Here is my table. How can I query by my id/Name and trust me ive tried

select from Quotes as Quotes ORDER BY ID/Name DESC

enter image description here

edit: you probably notice i have a dummyid. I do not want to use that row because I made it in a very hacky way and requires extra loading on the users side.

NightSkyCode
  • 1,141
  • 2
  • 16
  • 33

2 Answers2

1

Oh, dear. I see the problem, now. You have a column named ID/Name. It's usually wise to keep identifiers limited to alphanumeric characters.

Can you rename the column? That would be the best step forward.

If that's not an option, you can wrap it in backticks so that it's treated as an identifier:

SELECT * FROM Quotes ORDER BY `ID/Name` DESC;

See SQL Fiddle, which almost certainly won't match your schema but should get the point across.

rutter
  • 11,242
  • 1
  • 30
  • 46
  • Thanks rutter! works great now! and unfortunately not that I know of, google generated that column for me when I "generate my backend", I just design the models Google does the rest. Either way works now! ha – NightSkyCode Jul 27 '13 at 23:40
1

That Id/Name is the key field, imagine it is similar to primary key. to refer to that field in query, use

__key__
Example: select * from EntityTable where __key__ = Key('EntityTable', ....)

In your example, using date/time as key name is not really helpful, maybe you can find another info to be used as key.

marcadian
  • 2,608
  • 13
  • 20