Re: Combining several queries from Wordpress Database
Posted by:
Rick James
Date: December 30, 2014 11:21PM
JOIN wp_usermeta AS fn ON fn.id = u.id AND fn.meta_key="first_name" -- 3 new lines
JOIN wp_usermeta AS fn ON ln.id = u.id AND ln.meta_key="last_name"
JOIN wp_usermeta AS fn ON c.id = u.id AND c.meta_key="calibre"
-->
JOIN wp_usermeta AS fn ON fn.id = u.id AND fn.meta_key="first_name" -- 3 new lines
JOIN wp_usermeta AS ln ON ln.id = u.id AND ln.meta_key="last_name"
JOIN wp_usermeta AS c ON c.id = u.id AND c.meta_key="calibre"
My bad -- I failed to use different "aliases" for those two tables in this "self join".
Yeah, key-value schema. :(
The following change would help performance some:
CREATE TABLE `wp_usermeta` (
`umeta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) DEFAULT NULL,
`meta_value` longtext,
PRIMARY KEY (`umeta_id`),
KEY `user_id` (`user_id`),
KEY `meta_key` (`meta_key`)
) ENGINE=MyISAM AUTO_INCREMENT=9280 DEFAULT CHARSET=utf8
-->
CREATE TABLE `wp_usermeta` (
`user_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) DEFAULT NULL,
`meta_value` longtext,
PRIMARY KEY (`user_id`, `meta_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
Subject
Written By
Posted
December 26, 2014 12:52PM
December 28, 2014 12:51PM
December 29, 2014 09:10AM
Re: Combining several queries from Wordpress Database
December 30, 2014 11:21PM
December 31, 2014 05:46AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.