在MySqlDataReader

时间:2018-01-25 01:20:06

标签: c# mysql .net database

我想知道如何在使用JOIN时从表中选择查询?我想从表expires_at中选择列user_auth_tickets,但是如何将其添加到此查询中,我甚至可以访问它?看来我不能只使用dUserInfo.GetDateTime("expires_at"),因为如果两个表都有一个名为expires_at的列会怎么样?

dbConnection.SetQuery("SELECT users.id,users.username,users.rank,users.motto,users.look,users.gender,users.last_online,users.credits,users.activity_points,users.home_room,users.block_newfriends,users.hide_online,users.hide_inroom,users.vip,users.account_created,users.vip_points,users.machine_id,users.volume,users.chat_preference,users.focus_preference,users.pets_muted,users.bots_muted,users.advertising_report_blocked,users.last_change,users.gotw_points,users.ignore_invites,users.time_muted,users.allow_gifts,users.friend_bar_state,users.disable_forced_effects,users.allow_mimic,users.rank_vip " +
    "FROM users " +
    "JOIN user_auth_tickets " +
    "ON users.id = user_auth_tickets.user_id " +
    "WHERE user_auth_tickets.auth_ticket = @sso AND ip_last = @lastIp " +
    "LIMIT 1"
);

dbConnection.AppendParameter("sso", sessionTicket);
dbConnection.AppendParameter("lastIp", ipAddress);

using (var reader = dbConnection.ExecuteReader())
{
    if (!reader.HasRows)
    {
        errorCode = 1;
        return null;
    }

    dUserInfo = reader;
}

0 个答案:

没有答案