我有以下表格
nid timestamp title
82 1245157883 Home
61 1245100302 Minutes
132 1245097268 Sample Form
95 1245096985 Goals & Objectives
99 1245096952 Members
Run Code Online (Sandbox Code Playgroud)
和
pid src dst language
70 node/82 department/34-section-2
45 node/61/feed department/22-section-2/feed
26 node/15 department/department1/15-department1
303 node/101 department/101-section-4
Run Code Online (Sandbox Code Playgroud)
这些是表的片段,并且缺少其余的数据(它们都非常大),但我试图将第二个表中的dst列加入到第一个表中.它们应匹配"nid",但第二个表有节点/ [nid],这使得它更复杂.我也想忽略以"feed"结尾的那些,因为我不需要它.
非常感谢
编辑:我不好意思没有提到这个,但第一个表是一个sql结果来自
select nid, MAX(timestamp) as timestamp, title from node_revisions group by nid ORDER BY timestamp DESC LIMIT 0,5
Run Code Online (Sandbox Code Playgroud)
第二个表的名称为"url_alias"
尝试
select * from table1 inner join table2 on src=concat('node/',nid)
Run Code Online (Sandbox Code Playgroud)
编辑
编辑以反映OP中的更改
select `nid`, MAX(`timestamp`) as `timestamp`, `title` from `node_revisions` inner join `url_alias` on `src`=concat('node/',`nid`) group by `nid` ORDER BY `timestamp` DESC LIMIT 0,5
Run Code Online (Sandbox Code Playgroud)