例1,取得重定向数据。
复制代码 代码示例:
SELECT
p1.page_namespace,
ns_name,
p1.page_title
FROM redirect AS rd
JOIN page p1
ON rd.rd_from = p1.page_id
JOIN toolserver.namespace
ON p1.page_namespace = ns_id
AND dbname = 'enwiki_p'
LEFT JOIN page AS p2
ON rd_namespace = p2.page_namespace
AND rd_title = p2.page_title
WHERE rd_namespace >= 0
AND p2.page_namespace IS NULL
ORDER BY p1.page_namespace ASC;
说明: 取得重定向数据,逆序排列。
例2,取得跨域名空间的重定向数据。
复制代码 代码示例:
SELECT
pt.page_namespace,
pf.page_title,
ns_name,
rd_title
FROM redirect, page AS pf, page AS pt
JOIN toolserver.namespace
ON pt.page_namespace = ns_id
AND dbname = 'enwiki_p'
WHERE pf.page_namespace = 0
AND rd_title = pt.page_title
AND rd_namespace = pt.page_namespace
AND pt.page_namespace != 0
AND rd_from = pf.page_id
AND pf.page_namespace = 0;
说明: 获取跨域名空间的重定向数据。