I have two SQL tables:
users
from which I need all email addresess which looks like:
---------------------
| id | email | pass |
and user_answers
from which I need all unique question ids which looks like:
-------------------------------------------------
| id | question_id | user_id | date_registrated |
Each user can answer few times on one question, for short I need:
array => $users_array[0] = array($user[email], $user[uniqe_ids], $user[date_registrated])
$users_array[1] = ...
How can I do it? I tried:
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
and tried to sort it, bu with no effect.
Try this:
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
But this doesn't give anything meaningful to your scenario. kindly explain the scenario clearly.