Custom SQL SELECT query of 2 table
-
I have a very specific coding issue that needs resolution. I’m trying to query the wordpress wp_posts table for all posts that satisfy my parameters. They must have a custom field with meta_key=date and a meta_value for that row that is greater than 2:00am of today’s date. Here’s what I have so far:
SELECT * FROM wp_posts LEFT JOIN wp_postmeta ON wp_posts.ID=wp_postmeta.post_id WHERE meta_key = 'date' AND STR_TO_DATE(meta_value,'%m/%d/%Y') >= STR_TO_DATE('".date('Y-m-d 02:00:00')."', '%Y-%m-%d %H:%i:%s')";
The mysql_num_rows says it has 22 rows, but they each pertain to only one actual event in the wp_posts. There are actually over 25 entries that satisfy my parameters. Why am I getting one result instead of all 25? Is it solvable from just this code?
- The topic ‘Custom SQL SELECT query of 2 table’ is closed to new replies.