Sunday, 15 May 2011

sql server - Selects from multiple tables for Activities feed -


I have a social app for which I am trying to create a feed of friend activities using the Azure SQL Server.

I have 3 tables from which I want to select:

Lyrics-generated - myself-user-i-track -name-ATC

< p> comments -satedatt-user-IID-Saijiaidi -text

Pick-built -ait-user-Aisaiaidiaidiaidiaidi

the current users who have the user It is stored in an array called 'low'.

How do I know about choosing the most recent items out of those 3 tables where each table contains the userId array?

Edit:

  function getActivities (userId) {var deferred = Q.defer (); Var as follows: [=]; GetFollowing (userId) .then (function (result) {pius (user id); _.each (results, function (user) {pius (user.tusder);}); returns;}). Comments (0) (+ ("+" "+" + "" ("',' ') +"' "; Var query string =" Choose "Comments, Lyrics, Preferences Comments (" + Structured + ") or" "in the preferences. (" + Stracd + ") or. (" + Stringified + ")"; var Params = []; return Skyuelaf (query string, Params);}). then (function ( Result) {console .log ('actions:', result); suspended.rolove (result);}, function (error) {console.log ('error:', error message); deferred.reject (error .message);}); return deferred.}  

OK, so I dug a bit more in joints and realized how simple it really is, once you wrap your head around it, here I have done it to fulfill:

< pre> var Kweristring = "SELECT TOP 50 Followkid acid Follovid, Foloktusserid Es Follotousserid, Folokfromusserid Es Follofromusserid, Kmentsktekst Es Kmenttest, Profailskusserid, Profailskugrnam, Profailsknam, profiles. ProfileImage, songs.trackId, songs.trackName, song. Artists, songs, songs, songs, .artworkUrl100, songs, captions, songs. Songs in the form of ID, activities ActivityId, activity type as activities.Type, Object ID as activities.objectId activity, Activities.parentType AS ActivityParentType, Activities ParentId as activities.ParentId, activities .___1 "activities created in the form of built-in activity"; QueryString + = "INNER jOIN profile (Profailkyusraidi = Gtividhiankyusraidi)"; QueryString + = "LEFT jOIN songs on (songs.id = activities.objectId and activities.type = 'songs') or (Songskid = Activities.parentId and activities.parentType = 'songs') "; QueryString + =" Join the comments at the left ( activities.type = 'comments' and comments.id = activities.objectId) "; QueryString + =" left pair is the following (activities.Type = 'follow' and activities. Usserd = follows.fromUserId) "; QueryString + =" WHERE Gtividhionkupyogkrta iN (SELECT follow.toUserId as userId after following .fromUserId =? and follows.isFollowed = 'true') "; QueryString + =" activity "on .__ built Diissi by order; Var Params = [userId ]; Mssql.query (queryString, params, {success: work (results) {_.each (results, work (results) {// blank or undefined values ​​for the extracted columns (resulting i var) {if (result [i] === faucet || result [i] === undefined) {delete the result [i];}}}); response.send (200, result);}, error: function (error) {response.send (400, error message);}});

No comments:

Post a Comment