2

I have two entities: Cars (ownerId->String) and Users (userId->String), where ownerId is the foreign key representing userId.

I am trying to execute this Query, but I get "GQL syntax" at Datastore Viewer. How can I do this SUBSELECT?

SELECT * FROM Cars WHERE ownerId IN (SELECT userId FROM Users);
  • 3
    You can't. GQL is not SQL. You will need to to do one select, then iterate and fetch/filter or do two selects and merge in code. Alternately add a flag in the Car object that tells you that the Owner is a User, then you don't need to. – Tim Hoffman Apr 28 '13 at 11:16
  • @Tim - you should make this into an answer. – Peter Knego Apr 28 '13 at 13:22

1 Answers1

1

You can't. GQL is not SQL.

You will need to to do one select, then iterate and fetch/filter or do two selects and merge in code.

Alternately add a flag in the Car object that tells you that the Owner is a User, then you don't need to

If you are not trying to write code, but just explore then the remote_api shell is a place to try these things. Though this is much easier in python ;-)

Tim Hoffman
  • 12,976
  • 1
  • 17
  • 29