[wp-trac] [WordPress Trac] #49429: There seems to be no way to check query value for NULL

WordPress Trac noreply at wordpress.org
Fri Feb 14 04:56:53 UTC 2020


#49429: There seems to be no way to check query value for NULL
-------------------------+-----------------------------
 Reporter:  Jossnaz      |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:  5.3.2
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 NOT EXISTS and EXISTS both don't do what I want

 I want to check `WHERE meta_value IS NOT NULL`



 exists does this, applied to meta field

 related_post_id2:

 `
 "where" "mt5.meta_key = 'related_post_id2'"
 "join"  " INNER JOIN wp_2_postmeta AS mt5 ON ( wp_2_posts.ID = mt5.post_id
 )"
 `

 that is not what I want

 NOT EXISTS does:

 `
 "where" "mt5.post_id IS NULL"
 "join"  " LEFT JOIN wp_2_postmeta AS mt5 ON (wp_2_posts.ID = mt5.post_id
 AND mt5.meta_key = 'related_post_id2' )"
 `

 well, thats not what I want either, because now it checks "if there is a
 row with related_post_id2".


 I want

 "A row where the meta_value is not null"


 in reality what I want is

 Any entry, that has:
 No value for related_post_id2
 empty string for related_post_id2
 or
 null for related_post_id2


 does that make sense?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49429>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list