mysql - SQL Limit & Order By across joins -


I am accumulating tweets, twitter user and categorizing twitter user in groups.

I have the following 4 tables

Tweets:

  tweet_id | User_id | Created --------------------------- 23452345 | 2345 | 2013-08-12 23456094 | 1234 | 2014-03-24 230 9 7777 | 1234 | 2014-04-12 23 948798 | 99 99 | 2013-09-22   

twitter_users:

  user_id | Screen_name ------------------------ 2345 | Michael 1234 | David 99 99 | Not_interested   

twitter_social:

  user_id | Social_id ------------------------- 2345 | 34 99 99 | 20 1234 | 80   

Social Tags:

  social_id | Category_ID ----------------------- 34 | 3 20 6 80 3   

I want to see the oldest tweet per user that appears in a specific social category. The written SQL I wrote does not seem to work. I have a line per twitter_user but I do not see the tweet as soon as possible

  select tu.screen_name as handle, in the form of tw.created_at In the first twitter_users tu LEFT JOIN tweets on twitter.tu.user_id = tw.user_id LEFT JOIN twitter_social ts ON ts.user_id = tu.user_id LEFT JOIN social_categories CS ON ts.social_id = cs.social_id WHERE cs.category_id = 3 group By order   

edit by the oldest ASC I have to have the result as follows

  handle | Oldest --------------------- David | 2014-03-24 Michael | 2013-08-12    

  SELECT tu.screen_name In the form of handles, Leave twitter_users tu as MIN (Tw.created_at) first tu.user_id = tw.user_id Join tweets twitter_social ts Leave ts.user_id = tu.user_id on social relations cs tssocial_id = cs.social_id where Cs.category_id = 3 group by the tu.screen_name command, the oldest ASC    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -