0

我有两个 SQL 表:

users我需要所有电子邮件地址,如下所示:

---------------------
| id | email | pass | 

并且user_answers我需要所有独特的问题ID,如下所示:

-------------------------------------------------
| id | question_id | user_id | date_registrated |

每个用户可以在一个问题上回答几次,简而言之,我需要:

array => $users_array[0] = array($user[email], $user[uniqe_ids], $user[date_registrated])
$users_array[1] = ...

我该怎么做?我试过了:

SELECT * FROM `".USERS_TABLE."` AS u LEFT JOIN `".QUESTION_TABLE."` AS c ON u.id = c.user_id
WHERE user_admin =".$user_id." ORDER BY u.email

并试图对其进行排序,但没有任何效果。

4

1 回答 1

0

尝试这个:

select u.id,u.email,u.user_answers, c.question_id, c.date_registered
from USERS_TABLE AS u LEFT JOIN QUESTION_TABLE AS c 
ON u.id = c.user_id
where u.id = ".$user_id." 
ORDER BY u.email asc

但这对您的场景没有任何意义。请清楚地解释这个场景。

于 2013-05-16T19:10:51.867 回答