Skip to content

Instantly share code, notes, and snippets.

@Konctantin
Created January 3, 2017 22:02
Show Gist options
  • Select an option

  • Save Konctantin/8d999eb6c45ad12503f7a36600742c1e to your computer and use it in GitHub Desktop.

Select an option

Save Konctantin/8d999eb6c45ad12503f7a36600742c1e to your computer and use it in GitHub Desktop.
-- drop TEMPORARY TABLE IF EXISTS tmp;
CREATE TEMPORARY TABLE
IF NOT EXISTS tmp AS (
SELECT
t.entry,
t.`name`,
t.castBarCaption,
l.name_loc8,
l.castbarcaption_loc8
FROM
gameobject_template AS t
LEFT JOIN locales_gameobject AS l ON l.entry = t.entry
);
CREATE TEMPORARY TABLE
IF NOT EXISTS tmp2 AS (
SELECT
t.entry,
t.`name`,
t.castBarCaption,
l.name_loc8,
l.castbarcaption_loc8
FROM
gameobject_template AS t
LEFT JOIN locales_gameobject AS l ON l.entry = t.entry
);
drop TEMPORARY TABLE IF EXISTS result;
CREATE TEMPORARY TABLE
IF NOT EXISTS result AS (
SELECT tm.*
,(SELECT t2.name_loc8
FROM tmp2 AS t2
WHERE t2.`name` = tm.`name` and ifnull(t2.name_loc8,'')<>''
ORDER BY t2.name_loc8
LIMIT 1) as new_loc
FROM tmp as tm
where name_loc8 is null
);
select * from result where new_loc is not null
order by new_loc, entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment