MySQL Left Join Help -


OK, so I'm using PHP and MySQL to create a Clan Roster page. I have several different tables for which I have to use for this query. Here's how my tables are laid out:

  • Members - Regular members table
  • roster_members - memberID, GameID, rosterXP (experience points that the user earned for the roster
  • Select cr.id as crid, rank_title as cr.title, cr.minimumxp as rank_min, rank_abbr as cr.abport, cr.image rank_image In form, as member_id, rm.rosterxp roster_xp, from rm.gameid as game_id as rm.memberid ".db_PREFIX." Roster_members include rm left as ".db_PREFIX." In crore as clan_ranks (cr.minimumXP & lt; rm.rosterXP) where rm.gameID = ". $ GameID." Group by CR.id order rm.rosterXP DESC

    I think I can understand what your goal is if yes, I do not think that you mean that you want to create a group based on clan ranks, as you say - I think you are on the clan ranks. Are saying to be based.

      SELECT rm.memberid AS member_id, as rm.rosterxp roster_xp, as rm.gameid game_id, crid, cr.title as rank_title, cr.minimumxp as rank_min , Cr.abage as rank_abbr, cr.image from roster_members as r rank_image as CR.ID as rm left clan_ranks as cr.minimumXP at million = (clan_ranks CRM select CRM.minimumXP Where the minimumXP DESC range by crm.minimumXP & lt; rm.rosterXP order1) Where rm.gameID =: rm.rosterXP by DESC the game_id command   

    join left Only required if you are in the roster_members.rosterXP that> are at their lowest clan_ranks.minimumXP not is the case, then INNER JOIN will suffice.

          Li> A INNER JOIN will restrict the results to records that are completely match 'both' <'> section
        • a LEFT JOIN < / Li>
        • / code> indicates that joining 'left' will include all records of the specified table (s), even if the record is on the 'right' table ( S). If the records are not present, the NULL values ​​for each field defined for that table will be replaced.
        • Behind a right join only one LEFT JOIN

          Note that I have rearranged the fields in the field, it is for readability based on the probability of the records present in the clan_ranks if they are not present , Then the field that will look first will contain data (from roster_mailers), and in the result set the field on the right will be further NULL . This is not a requirement in any way - just a conference.

          In addition, I removed the database prefix and added a placeholder for readability.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -