I have a view that I'd like to filter by uid, so that it only shows one node per user. I've posted in the forum but my topic quickly got lost among all the others. Hoping someone will notice this here.

I've made some changes to my views_user.inc but they didn't help...

http://drupal.org/node/264561

Comments

merlinofchaos’s picture

Status: Active » Closed (won't fix)

This kind of query isn't really possible with Views.

norio’s picture

@merlinofchaos,

Thanks for your reply! Much appreciated :)

I'm a seasoned PHP developer so I'd be happy to code something up that would make it possible with views. If you could take a look at my code here and let me know what I'm doing wrong (I'm new to the views API), I would be able to cook something up and post it here for everyone to use.

norio’s picture

Assigned: Unassigned » norio
Category: support » feature
Status: Closed (won't fix) » Postponed (maintainer needs more info)

Seriously happy to take this on, if you could spare me some basic advice.

merlinofchaos’s picture

Unfortunately, it's really hard to do with SQL, as in, I've never come up with a good way to do it. Sometimes you can do it using GROUP BY (which Views supports only very, very poorly) but once you GROUP BY you pretty much lose access to fields that you aren't grouping on, except for calculations. You can't really specify just one record out of everything that's being grouped.

Generally I've had to resort to multiple queries to do stuff like that, and that means not using Views. Sorry.

norio’s picture

Okie dokes, thanks in any case :)

carnage_’s picture

surely DISTINCT (uid) Would do the job?

merlinofchaos’s picture

Unfortunately, Views doesn't support that. I also suspect that in the real world, it would probably only work sometimes. MySQL seems to be fussy about distinct.

sun’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

Consider upgrading to 6.x, please.

doublejosh’s picture

Can I do this in Views 2 without the Views Group By module?