如何在SQL中连接3个表

时间:2015-07-03 10:51:13

标签: php

这是我创建的查询:

public string GetOAuthToken(IUser user) {
    if (user  != null) {
        var identity = new ClaimsIdentity(Startup.OAuthOptions.AuthenticationType);
        identity.AddClaim(new Claim(ClaimTypes.Name, user.UserName));
        identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id));
        AuthenticationTicket ticket = new AuthenticationTicket(identity, new AuthenticationProperties());
        var currentUtc = DateTime.UtcNow;
        ticket.Properties.IssuedUtc = currentUtc;
        ticket.Properties.ExpiresUtc = currentUtc.Add(TimeSpan.FromDays(36600)); //About 100 years
        string AccessToken = Startup.OAuthOptions.AccessTokenFormat.Protect(ticket);
        return AccessToken;
    }
    return "";
}

2 个答案:

答案 0 :(得分:0)

尝试使用此查询。

> $a 
a
c
> $b
b

答案 1 :(得分:0)

首先,您应该使用别名以获得更好的可读性,

检查你是否在$ _GET [id]

中得到了什么
    echo $_GET[id];

然后分配它,(或者你可以设置它,如果你正在使用一个类)

    $fltr = $_GET[id];

然后,尝试使用LEFT JOIN;

    SELECT   b.company,     b.po_box, 
             b.town,        a.address_id, 
             a.attn,        a.create_date,
             a.ref_no,      a.refference, 
             a.letter_body, a.print_date 
    FROM     letter_details AS a LEFT JOIN address_details AS b ON b.id = a.address_id
                                 LEFT JOIN signatories     AS c ON (a.id =c.id) 
    WHERE    a.id='$fltr'