\$\begingroup\$
\$\endgroup\$
6
I was able to pull the records I wanted but I have a feeling it could be written better for these particular MySQL query strings.
SELECT ID,XAxis,YAxis,Player,Castle,Alliance FROM SC75
WHERE Snap = (SELECT MAX(SavedSnap) FROM DataSnap WHERE Server = 75)
AND hex(Player) IN (hex('Vandiel'))
UNION
SELECT SC.ID,XAxis,YAxis,SC.Player,Castle,Alliance FROM SC75 AS SC
INNER JOIN AltFiller AS AF ON hex(AF.Player) IN (hex('Vandiel'))
WHERE SC.Player = AF.Alts
AND Snap = (SELECT MAX(SavedSnap) FROM DataSnap WHERE Server = 75)
ORDER BY Player,Castle
Jamal
35.2k13 gold badges134 silver badges238 bronze badges
1 Answer 1
\$\begingroup\$
\$\endgroup\$
The two parts to the UNION
have too much in common. I believe this query is equivalent to yours.
SELECT ID, XAxis, YAxis, Player, Castle, Alliance
FROM SC75
WHERE
Snap = (SELECT MAX(SavedSnap) FROM DataSnap WHERE Server = 75)
AND
(
(hex(Player) IN (hex('Vandiel'))
OR
Player IN
(
SELECT AF.Alts
FROM AltFiller AS AF
WHERE hex(AF.Player) IN (hex('Vandiel'))
)
)
ORDER BY Player, Castle;
answered Aug 28, 2013 at 7:39
lang-sql
SC75
? Does that mean that you also have tablesSC74
,SC73
and so forth? Does the75
inSC75
relate toServer = 75
? If you posted the schema, I could have some comments. \$\endgroup\$