mysql - Select data based on another table -
i have 3 tables, i'll list important columns
db_players
id | name
players
id | teamid | careerid
db_teams
the db_teams id links players teamid.
i need run query select rows db_players long db_teams.id isn't in row in players teamid careerid = 1.
i've never attempted type of query mysql before, know 2 queries , involve php i'm intrigued whether it's possible pure db query.
thanks.
edit - simpler now.
select dp.first_name tbl_foot_career_db_players dp inner join tbl_foot_career_players p on p.playerid != dp.id p.careerid = 1
the idea want return rows tbl_foot_career_db_players id table isn't present in row in tbl_foot_career_players in column playerid. , tbl_foot_career_players.careerid must equal 1.
list db_players not in players career = 1
select d.* db_players d left join players p on p.player_id = d.id , p.career = 1 p.id null
Comments
Post a Comment