I just started working with Drupal 7 and I'm stuck at something I believe should be really easy (I could easily write it using plain SQL).
I have a query, rather complex (but that's not relevant) which I wanted to extend with hook_views_query_alter. What I need to achieve:
Based on base table users I need to:
- Join a table node based on users.uid (many-to-one)
- Then join a table node_param on node.id (one-to-one)
- select count(node_param.id) WHERE node_param.value is greater than X
- Order everything based on that count field
I've done research on Drupal website and stackoverflow, but couldn't find anything that would actually work, everything I've tried ended up with no results at all and I did build the query with SQL that returns results - therefore I believe my altered query gone wrong.
I will really appreciate your help here! :)
P.S. I can only modify this query using this hook!