-5

我在 sql 中有 3 个表,如下所示:(需要 sql 语法)

1

.xy8vx_users
-username
-email
-....

2

.xy8vx_rsform_submissions
-SubmissionId
-Username
-...

3

.xy8vx_rsform_submissions_values
-SubmissionId
-FieldName
-FieldValue
-...

我想得到: xy8vx_users.username, and xy8vx_users.email,满足条件

submission_values.FieldName = 'data2' AND submission_values.FieldValue = '10.03.2012'

我已经花了 2 个小时,没有人可以帮助我吗?

我试过这个:(但不工作)

SELECT sub.Username
FROM `xy8vx_rsform_submission_values` AS value
JOIN `xy8vx_rsform_submissions` AS sub ON value.SubmissionId = sub.SubmissionId
JOIN xy8vx_users ` AS users ON sub.Username = users.email WHERE value.FieldName = 'data2' AND value.FieldValue = '10.03.2012'`
4

1 回答 1

1
select xy8vx_users.username, xy8vx_users,email
from
submission_values 
inner join
submissions on 
submission_values.SubmissionId = submissions.SubmissionId
inner join
xy8vx_users on
submissions.Username = xy8vx_users.username
where 
submission_values.FieldName = 'data2'
and 
submission_values.FieldValue = '10.03.2012'
于 2012-10-03T22:52:20.390 回答