views:

497

answers:

2
List_name   Email
==========  ==================
andrew      [email protected]
adam        [email protected]
smith       [email protected]
john        [email protected]
andrew      [email protected]
adam        [email protected]
smith       [email protected]
john        [email protected]
andrew      [email protected]
adam        [email protected]
smith       [email protected]
john        [email protected]
andrew      [email protected]
adam        [email protected]
smith       [email protected]
john        [email protected]

In the above table email_ids are repeated, I want to display all emails in the above table with out repetition.

Here there is only 4 emails, I want to retrieve only 4 rows from table is this possible using GQL query in goolge app engine.

And one more thing i want to use paging to display emails (10 emails for a page),

i.e., if there is 15 emails in table, need to display 10 emails in 1ST page and 5 emails in 2nd page.

Paging is very important!

+3  A: 

If you're accustomed to working with a relational database, Google App Engine can seem unusual. The query syntax is very limited. Instead of putting everything into a simple table and writing complicated queries, you have to put everything into complicated data structures and then write simple queries.

You should get used to creating several different Entities, usually one for each primary key for a possible query. In this case, you should have an Entity UniqueEmailAddress or something like that. Every time you add a record, get the UniqueEmailAddress with that name and update it, or create it if it doesn't exist. Then you can just query on UniqueEmailAddress directly.

dmazzoni
+1. For instance, no SELECT DISTINCT in GQL
codeape
+1 for the succinct summary of the situation in the third sentence.
Peter Recore
+1  A: 

You can use the set function in python you will be able to remove all the duplication. I don't think there is a way of doing it GQL.

>>> basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
>>> fruit = set(basket)               # create a set without duplicates
>>> fruit
set(['orange', 'pear', 'apple', 'banana'])
AutomatedTester
Note that this solution will require fetching all the records in the 'table', which won't scale very well, and doesn't support paging very well.
Peter Recore