UPDATE `table` SET
`email` = IF(LOCATE('Мыло|', `info`) = 0, NULL,
SUBSTRING_INDEX(SUBSTRING_INDEX(`info`, 'Мыло|', -1), '|', 1)),
`phone` = IF(LOCATE('Телефон|', `info`) = 0, NULL,
SUBSTRING_INDEX(SUBSTRING_INDEX(`info`, 'Телефон|', -1), '|', 1)),
`skype` = IF(LOCATE('Skype|', `info`) = 0, NULL,
SUBSTRING_INDEX(SUBSTRING_INDEX(`info`, 'Skype|', -1), '|', 1));
SELECT `p`.`thread_id`
FROM `msg_participants` AS `p`
JOIN `msg_participants` AS `t` USING(`thread_id`)
WHERE `p`.`user_id` = ?
AND `t`.`user_id` = ?
SELECT `p`.`thread_id`
FROM (SELECT `thread_id` FROM `msg_participants` WHERE `user_id` = ?)
AS `p`
JOIN (SELECT `thread_id` FROM `msg_participants` WHERE `user_id` = ?)
AS `t` USING(`thread_id`)
SELECT `jp`.*, `ji`.`image`
FROM `jml_jquery_plugins` AS `jp`
LEFT JOIN `jml_jquery_images` as `ji`
ON `ji`.`pluginid` = `jp`.`id`
LEFT JOIN (SELECT MIN(`id`) AS `min`, `pluginid` FROM `jml_jquery_images` GROUP BY `pluginid`) AS `t`
ON `t`.`pluginid` = `jp`.`id`
WHERE `jp`.`del` != 1
AND `jp`.`lastupdate` > 0
AND (`t`.`min` = `ji`.`id` OR `ji`.`image` IS NULL)
ORDER `jp`.`name` ASC
LIMIT 20