sql - Determine if column value is null/non-null in MySQL -
i have 2 tables, 1 containing user data, user, , second contains users have tied accounts in twitter, user_twitter. second table not contain correspodning value each user (those have yet connect account twitter, instance), querying using left join:
select distinct `user_twitter`.uid `connected` `user` left join (select uid `user_twitter`) `user_twitter` on `user`.uid = `user_twitter`.uid what i'd return boolean value (true if user_twitter.uid non-null value, false if null). pointers?
select a.uid `connected`, (b.uid not null) bool_val `user` left join `user_twitter` b on a.uid = b.uid will return 0 false , 1 true. if want string value true or false,
select a.uid `connected`, case when b.uid not null 'true' else 'false' end bool_val `user` left join `user_twitter` b on a.uid = b.uid
Comments
Post a Comment