De er tabelaliaser, så du behøver ikke at angive hele tabellens navn, når du skal lave reference.
For kun at få de ulige nummererede poster, brug:
SELECT x.*
FROM (SELECT u.pg_id AS ID,
u.pg_url AS URL,
u.pg_title AS Title,
u.pg_content_1 AS Content,
@rownum := @rownum + 1 AS rownum
FROM root_pages u
JOIN (SELECT @rownum := 0) r
WHERE u.parent_id = '7'
AND u.pg_id != '7'
AND u.pg_cat_id = '2'
AND u.pg_hide != '1'
ORDER BY u.pg_created DESC) x
WHERE x.rownum % 2 != 0
For at få de lige nummererede poster, brug:
SELECT x.*
FROM (SELECT u.pg_id AS ID,
u.pg_url AS URL,
u.pg_title AS Title,
u.pg_content_1 AS Content,
@rownum := @rownum + 1 AS rownum
FROM root_pages u
JOIN (SELECT @rownum := 0) r
WHERE u.parent_id = '7'
AND u.pg_id != '7'
AND u.pg_cat_id = '2'
AND u.pg_hide != '1'
ORDER BY u.pg_created DESC) x
WHERE x.rownum % 2 = 0
Forklaring
%
er moduloperatoren i MySQL-syntaks -- den returnerer resten af divisionen. For eksempel er 1 % 2 0,5, mens 2 % 2 er nul. Dette bruges derefter i WHERE-sætningen til at filtrere de viste rækker.