0

我正在尝试从 wordpress 数据库中检索数据。我在查询中找不到语法错误,有人可以帮我解决这个问题吗?

它是列出特定的前 10 个帖子,post_type并将其Events_Date字段转换为日期时间。

这是我的查询:

SELECT wp_posts.*, wp_postmeta.* 
FROM ritmica_wp.wp_posts, ritmica_wp.wp_postmeta
WHERE convert(datetime, wp_postmeta.meta_value, 120) > GetDate() 
IN
    (SELECT wp_posts.*, wp_postmeta.* FROM ritmica_wp.wp_posts, ritmica_wp.wp_postmeta 
    WHERE wp_posts.post_type = 'event' 
    AND wp_postmeta.meta_key = 'Events_Date' )

ORDER BY wp_postmeta.meta_value ASC LIMIT 10
4

1 回答 1

0

我没有看到子查询的意义。你不能这样做:

SELECT TOP 10
    wp_posts.*, wp_postmeta.* 
FROM
    ritmica_wp.wp_posts, ritmica_wp.wp_postmeta
WHERE
    convert(datetime, wp_postmeta.meta_value, 120) > GetDate() 
    AND wp_posts.post_type = 'event' 
    AND wp_postmeta.meta_key = 'Events_Date'
ORDER BY
    wp_postmeta.meta_value ASC

(对于 SQL Server)

于 2013-01-30T11:00:35.807 回答