SELECT
CASE
WHEN n.nid IS NOT NULL THEN n.nid
ELSE u.uid
END AS 'id',
CASE
WHEN n.title IS NOT NULL THEN n.title
ELSE u.name
END AS 'title',
CASE
WHEN n.type IS NOT NULL THEN n.type
ELSE 'user'
END AS 'type',
ua.alias
FROM
url_alias ua
LEFT JOIN node n ON
n.nid = REPLACE(ua.source, 'node/', '')
LEFT JOIN users u ON
u.uid = REPLACE(ua.source, 'user/', '')
WHERE
(n.type IN ('page', 'article')
AND n.status = 1)
OR u.status = 1;
Note that this only returns active users and published nodes of the type 'page' and 'article'. Useful for migration purposes.
Add new comment