mercredi 19 juillet 2017

Get random record using like query in postgres

I am having an table with email_address as a primary key and there is no id column in the table.

So whenever I hit the query like

select email_address from data  where email_address like '%@gmail.com' limit 10

it gives result alphabetically means all the email-id starting with a (if its present).

But I don't want like alphabetic order, I want result like

email_address
___________________
a@gmail.com
k@gmail.com
d@gmail.com
b@gmail.com

Pick randomly email address which ends with gmail.com, not by inserted order or not by alphabetic order.




Aucun commentaire:

Enregistrer un commentaire