YQL 相当于 MySQL 的“INTERVAL”?
我有一个在 PHP/MySQL 中运行的职位发布板,并考虑尝试在 YQL 和 Google Docs 中运行它。我有一行 MySQL 只获取过去 60 天内发布的职位发布:
$sql = "SELECT * FROM `job` WHERE Curdate( ) <= DATE_ADD( `postdate` , INTERVAL 60 DAY ) ORDER BY `postdate` DESC;";
是否有与此等效的 YQL? (Google 文档中表单提交的电子表格中时间戳列的格式为:
2/11/2011 10:23:37
I have a job postings board that I'm running in PHP/MySQL and thinking of trying to run it in YQL and Google Docs instead. I have a line of MySQL that fetches job postings that have been posted in the last 60 days only:
$sql = "SELECT * FROM `job` WHERE Curdate( ) <= DATE_ADD( `postdate` , INTERVAL 60 DAY ) ORDER BY `postdate` DESC;";
Is there a YQL equivalent of this? (The format of the timestamp column in the spreadsheet of form submissions in Google Docs is:
2/11/2011 10:23:37
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
YQL 目前没有在查询中使用自定义函数的选项,因此您的
Curdate()
、DATE_ADD()
等是不可能的。但是,您没有理由不能制作如下查询:其中
$date
是整数时间戳(如果您的 Google 文档中提供了该查询?)。或者,后一个查询需要定制的数据表来解释查询参数并根据您的 Google 文档格式化查询。制作自己的表的一个优点是您可以使用 JavaScript(在
块中)在 YQL 中执行服务器端处理(就像 PHP 中的处理一样)。YQL doesn't currently have the option of custom functions within queries, so your
Curdate()
,DATE_ADD()
, etc. are out of the question. However, there is no reason why you could not craft queries like:Where
$date
is an integer timestamp (if that is available in your Google doc?). Or,This latter query would need a bespoke Data Table to interpret the query parameter(s) and format a query against your Google doc. An advantage of crafting your own table would be that you are able to use JavaScript (in an
<execute>
block) to perform server-side processing (like one would in PHP) in YQL.