Reputation: 153
I have two tables
taxonomy_index
-nid
-tid
and
url_alias
-source
-alias
I need to find url_alias.alias
record which have source 'taxonomy/term/' + taxonomy_index.tid
and I have only taxonomy_index.nid
Upvotes: 1
Views: 380
Reputation: 9861
This query will do that for you although there may be more efficient way to do this ;)
SELECT
T.nid
,U.*
FROM
url_alias AS U
INNER JOIN (
SELECT
nid
,CONCAT('taxonomy/term/', tid) AS `alias`
FROM
taxonomy_index ) AS T
ON
U.alias = T.alias
Upvotes: 1
Reputation: 1122
SELECT url_alias.alias
FROM url_alias, taxonomy_index
WHERE url_alias.source = CONCATENATE('taxonomy/term/', taxonomy_index.tid)
AND taxonomy_index.nid = {given_nid}
Upvotes: 4
Reputation: 39763
Either use a subquery or a join. With a subquery:
SELECT alias
FROM url_alias
WHERE source =
(SELECT CONCAT('taxonomy/term/',tid)
FROM taxonomy_index
WHERE nid = ?
)
Upvotes: 1