柳暗花明笔记

    一个很值得我学习和收藏的sql语句

    所属分类:[ linux&mysql ] 猫哲学家 发表于:2012-07-31 23:09 浏览:383

    SELECT node.nid AS nid,    node.created AS node_created FROM node node LEFT JOIN content_type_activity node_data_field_activity_end_time ON node.vid = node_data_field_activity_end_time.vid WHERE (node.type in ('activity'))     AND (DATE_FORMAT(ADDTIME(STR_TO_DATE(node_data_field_activity_end_time.field_activity_end_time_value, '%Y-%m-%dT%T'), SEC_TO_TIME(28800)), '%Y-%m-%d\T%H:%i:%s') > DATE_FORMAT(NOW(),'%Y-%m-%d\T%H:%i:%s'))    ORDER BY node_created DESC

    但这个sql语句在drupal 下的db_query写法是这样的:

    SELECT node.nid AS nid,    node.created AS node_created FROM node node LEFT JOIN content_type_activity node_data_field_activity_end_time ON node.vid = node_data_field_activity_end_time.vid WHERE (node.type in ('activity'))     AND (DATE_FORMAT(ADDTIME(STR_TO_DATE(node_data_field_activity_end_time.field_activity_end_time_value, '%%Y-%%m-%%dT%%T'), SEC_TO_TIME(28800)), '%%Y-%%m-%%d\T%%H:%%i:%%s') > DATE_FORMAT(NOW(),'%%Y-%%m-%%d\T%%H:%%i:%%s'))    ORDER BY node_created DESC
    标签: mysql 
    上一编文章 ubuntu 下方便的右键svn菜单 下一编文章 javascript页面定时跳转参考
    最近文章
    发表评论