开发者

Trying to join data from two mysql tables in order to sort by it

开发者 https://www.devze.com 2023-01-20 02:09 出处:网络
I\'m currently working on Drupal site, building a custom JSON module for a project at work. I\'m trying to join data of events from the drupal node table to a date field associated with it, stored in

I'm currently working on Drupal site, building a custom JSON module for a project at work.

I'm trying to join data of events from the drupal node table to a date field associated with it, stored in another table. This cannot be altered.

What i want to do, is run a query to fetch the list of events from the node tab开发者_如何学编程le, and but i need to order the list returned by the timestamp in the date field, which is stored in the other table.

The two are related by their 'nid' (node id).

I realise this is probably quite simple in terms of relational databases, but i've never written a relational query in my life, so please educate me :)

Thanks.


SELECT
   t1.event
FROM
   t1
   JOIN t2 ON t1.nid = t2.nid
ORDER BY
   t2.time
0

精彩评论

暂无评论...
验证码 换一张
取 消