MySQL Forums
Forum List  »  Newbie

Re: Query challengers table
Posted by: Peter Brawley
Date: June 10, 2022 05:02PM

Please post Show Create table result and Inserts for the other table.

SQL is not so good at changing Join rules depending on key values or magic numbers. The fact that this query tries to do so indicates an issue with the underlying data model.

If you're committed for some reason to that data model, you'd probably be best off collecting all possible joined data in an inner query, something like ...

select 
  c.challenger_user_id, challenger_id, c.user_id,
  u.user_id, u.first_name, u.last_name
from challengers c
join users a on c.challenger_id = a.user_id
join users b on c.user_id = b.user_id

... then picking off desired data-dependent values in an outer query.

If OTOH you're open to clarifying the data model, please explain what's so special about user 1001.

Options: ReplyQuote


Subject
Written By
Posted
June 10, 2022 01:56PM
Re: Query challengers table
June 10, 2022 05:02PM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.