I have a pgsql table with names (more than 1 million rows), but I also have a lot of duplicates. I select 3 fields: id , name , metadata .
I want to randomly select them using ORDER BY RANDOM() and LIMIT 1000 , so I do this many steps to save some memory in my PHP script.
But how can I do this, so it gives me a list without duplicates in the names.
For example, [1,"Michael Fox","2003-03-03,34,M,4545"] will be returned, but not [2,"Michael Fox","1989-02-23,M,5633"] . The name field is the most important and should be unique on the list every time I make a choice, and it should be random.
I tried with GROUP BY name , bu, then it expects that I have id and metadata in GROUP BY , as well as in the aggragate function, but I do not want them to be filtered in some way.
Does anyone know how to extract many columns, but only make individual columns?
select postgresql distinct
NovumCoder Jun 04 '13 at 9:14 2013-06-04 09:14
source share