English 中文(简体)
que?
原标题:what can be the sql query?

我有2个表格tbl_UserRegistrationtbl_Streaks,其结构如下:

<>斯特隆>UserRegistration

               DATATYPE   LENGTH
UserName       Text         25  (PRIMARY KEY)
PhotoLink      Text        150  
DeviceToken    Integer      15
DeviceType     Integer       1

<>strong>tbl_Streaks

            DATA TYPE     LENGTH
ID          Integer         10 (PRIMARY KEY)
Player1     Text            25
Player2     Tex             25
Streaks     Integer         10

我现在想 f那些最有光线的势力。

EDITED :

 i.e. Player1, Player2, MAX(streak), Photolink

我如何能够这样做?

什么是q?

感谢。

NOTE-Player1 and Player2 and UserName are equal.

最佳回答

可以通过加入<条码>tbl_UserRegistration/code>,为两个用户检索<条码>。 为了让得分最重的参与者坐起来,你可以按排位顺序排列如下:<代码>。 缩略语

SELECT
  s.Player1,
  s.Player2,
  s.Streak,
  u1.PhotoLink AS PhotoLink1,
  u2.PhotoLink AS PhotoLink2
FROM tbl_Streaks s
  INNER JOIN tbl_UserRegistration u1 ON u1.UserName = s.Player1
  INNER JOIN tbl_UserRegistration u2 ON u2.UserName = s.Player2
ORDER BY s.Streak DESC
LIMIT 1
问题回答

假设用户名称与“运动员”1和“运动员”2 相同,那么你可以“青年网络” t。 缩略语 用户登记和在选任合同条款中发现,与运动员和运动员一起,Streaks的限额为2

下面是T-SQL,并将从每个用户中提取最高分数:

SELECT
    r.UserName 
    , MAX(s.Streaks) mx     
FROM 
    tbl_UserRegistration r
    INNER JOIN tbl_Streaks s ON
        r.UserName = s.Player1
GROUP BY
    r.UserName 




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签