2016-06-12 63 views
-1

我有两个表,我必须选择一些记录,并使用PHP脚本将它放在xls中。MySQL - 如何查询多个表并将结果放入xls?

我尝试不同的查询,但不工作。

在JOD_users表我需要选择ID,名称,用户名,电子邮件和JOD_user_profiles我需要选择profile_key和profile_value,但profile_value是在同一列(这是我的问题)。

tables structure

我怎么能有结果在单行?

非常感谢。

+0

profile_value在同一列?你什么意思? –

+0

要在多个表中进行查询,您可以使用JOIN进行映射并以csv或excel格式导出结果数据。 –

+1

@ user3421040请勿将图像用于基本上为文字的内容。 – Midas

回答

0

你可以做一个INNER JOIN这样的查询:

SELECT user.*, profile.* FROM JOD_users user INNER JOIN JOD_user_profile profile ON user.id = profile.user_id

-1

我通过化妆解决了这个查询我的foreach内。

选择JOD_user_profiles * 从JOD_user_profiles 其中JOD_user_profiles.user_id = “$按行>的ID。”和JOD_user_profiles.profile_key like'profile5。%'

非常感谢。

相关问题