热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

查询Wordpress数据库时MySQLLEFTJOIN错误1064-MySQLLEFTJOINerror1064whenqueryingWordpressdatabase

ImtryingtoretrievesomedatafromaWordpressdatabase:我正在尝试从Wordpress数据库中检索一些数据:SELECTM.met

I'm trying to retrieve some data from a Wordpress database:

我正在尝试从Wordpress数据库中检索一些数据:

SELECT M.meta_value,wp_users.ID
FROM wp_postmeta AS M 
WHERE meta_key = "_from_email" AND post_id = 277124
LEFT JOIN wp_users ON M.meta_value = wp_users.user_email

Here, my intention is to get the ID of the wp_users user who has an email identical to one in meta_value.

在这里,我的目的是获取w__users用户的ID,该用户的电子邮件与meta_value中的电子邮件相同。

But I get the following error:

但是我收到以下错误:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN wp_users ON M.meta_value = wp_users.user_email

1064 - 您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在'LEFT JOIN wp_users'附近使用正确的语法ON M.meta_value = wp_users.user_email

Do you see any syntax error?

你看到任何语法错误吗?

1 个解决方案

#1


1  

left join must be declare before where clause

left join必须在where子句之前声明

SELECT M.meta_value,wp_users.ID
FROM wp_postmeta AS M 
LEFT JOIN wp_users ON M.meta_value = wp_users.user_email
WHERE meta_key = "_from_email" AND post_id = 277124

be sure you are not using column for left joined table in where clause otherwise this implies that the join work as an inner join .. eventually move these column in the related ON clause

确保你没有在where子句中使用左连接表的列,否则这意味着连接作为内连接工作..最终在相关的ON子句中移动这些列


推荐阅读
author-avatar
俊维肇民74
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有