I'm trying to work with the wordpress database, specifically the wp_options table, and their structure looks like this: id option_name option_value and I need to pull about 8 enteries out of this table with a single query. I try this, but it pulls back wrong results: "SELECT option_value FROM wp_options WHERE option_name='blog_url' || option_name='blog_title' || option_name='blog_tagline' || option_name='blog_email' || option_name='blog_permalink' || option_name='blog_comments' || option_name='plugin_loading' || option_name='random_theme'" I am trying to pull these values out so I can set them into variables I don't know why the returned results come back wrong(some come back wrong, giving me values for the wrong option_name) Is there a better way to do this? ty adbox
SELECT `option_name` , `option_value` FROM `wp_options` WHERE `option_name` = 'blogname' || `option_name` = 'admin_email' || `option_name` = 'rss_excerpt_length' LIMIT 0 , 30 outputs option_name option_value admin_email blogname asdasda rss_excerpt_length 50
how this query is working pls let me know. Also let me know the difference between `wp_options` and wp_options
You don't need to use backticks unless you want to or you name a column using a reserved word like date, time, etc.. You can also do this: SELECT `option_name` , `option_value` FROM `wp_options` WHERE `option_name` IN ('blogname','admin_email','rss_excerpt_length') LIMIT 0 , 30 ;