Mysql queries missing data

 member_id 
  openID 
  mp_id  openID 

 openID  
** mp_id  openID ** sql  

SELECT * FROM `score_log` WHERE `mp_id` = "gh_1d3037ae656c" 
AND `openid` = "o5NHFsy-PUHxY7G_h_S8UscpKVg8" 

May.30,2022

I didn't understand the question. Don't you have the result?

openid is empty and should also be included in the result?


if openid is just an empty string

SELECT * FROM `score_log` WHERE `mp_id` = 'gh_1d3037ae656c' 
AND `openid` in ('o5NHFsy-PUHxY7G_h_S8UscpKVg8', '');

if openid is just null

SELECT * FROM `score_log` WHERE `mp_id` = 'gh_1d3037ae656c' 
AND (`openid` = 'o5NHFsy-PUHxY7G_h_S8UscpKVg8' OR openid is null);

as you said, you need mp_id and openID as conditional queries, then any condition should not satisfy the uniqueness of the record, otherwise you only need to meet the unique condition, then there will be no solution if the data is missing, and the records obtained can only be less than the records you should have. On the other hand, find out whether the business rules can make up for the missing data, or query it with other conditions that can only determine the user's record.

Menu