Skip to content

Instantly share code, notes, and snippets.

@softsolution
Last active August 29, 2015 14:23
Show Gist options
  • Save softsolution/2eba25d2113a25387999 to your computer and use it in GitHub Desktop.
Save softsolution/2eba25d2113a25387999 to your computer and use it in GitHub Desktop.
MySQL запросы
--копирование значений из одной таблицы в другую - связывание таблиц
UPDATE cms_blog_posts p, cms_hits h
SET h.owner_id = p.blog_id
WHERE h.target_id = p.id AND h.target = 'blogpost'
--расстояние до геоточек
--еще нужна функция MYSQL - позже добавлю
SET @src := Point('56.85479147340446','60.59969435180665');
SELECT i.*, DATE_FORMAT(i.pubdate, '%H:%i') as ftime, c.title as category, c.marker as marker, c.zoom as zoom , geodist(X(@src), Y(@src), i.lat, i.lng) AS distantion FROM cms_map_cats c, cms_map_items i WHERE i.published = 1 AND ((i.category_id = c.id) AND (c.NSLeft>=3 AND c.NSRight<=4)) AND (i.city_id = '5106')
GROUP BY i.id
ORDER BY distantion asc LIMIT 0, 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment