Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have three tables:
user (user_id)
question (question_id)
answer (question_id, answer_id, user_id)
How can I select the questions that a user didn't answer?
Thank you.
You question appears to be missing some information as user is not associated with question or answer in any way. Assuming that answer has (user_id, question_id, answer_id) or that answer only has answered questions in it you can do
SELECT question_id
FROM question q
WHERE NOT EXISTS(SELECT * FROM answer a WHERE a.question_id = q.question_id);
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a simple entry in the oracle, there are 3 columns, date, API name and status. I want that in the answer I had not all history, and only the last on each of Names of API (only 7). I will be grateful for your help. I know that asked of the very difficult but I'm just new to oracle.
select l.log_date,l.job_name,l.status from user_scheduler_job_log l
could be you want the related status for name and last log_date
select u.job_name, u.status, t.max_date
from user_scheduler_job_log u
INNER JOIN(
select MAX(l.log_date) max_date, l.job_name
from user_scheduler_job_log l
GROUP BY l.job_name
) t on t.max_date = u.log_date
AND t.job_name = u.job_name
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
So I have a table for biddings, you can win the bidding by posting the lowest unique bid. So if 2 people place a bet of $1, none of them win, if 1 person places a bet of $2, this guy wins. But how can I check this in MySQL?
Assume your table has the bid value stored in the field name bet, then below is a worked solution:
SELECT * FROM YourTableName
WHERE bet = (SELECT MIN(bet) FROM YourTableName)
GROUP BY bet
HAVING COUNT(*) = 1;
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have one table with 3 fields e.g.
Name, Team Name, Player_Number
there is multiple team and I want to fetch 2 member from each team.
Please share with fast solution.
Try this
select * from TableName s where (select count(*) from TableName a where a.TeamName = s.TeamName and a.Player_Number >= s.Player_Number) <= 2
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can I do this correctly?
INSERT INTO tbl_task (`Assignedby`,`userID`)
SELECT ID FROM tbl_users WHERE UserName='$_GET[u]',
SELECT ID FROM tbl_users WHERE UserName='$_GET[at]'
Assuming you want to insert one row with two columns, I think you might want this:
INSERT INTO tbl_task(`Assignedby`, `userID`)
SELECT (SELECT ID FROM tbl_users WHERE UserName='$_GET[u]'),
(SELECT ID FROM tbl_users WHERE UserName='$_GET[at]');
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a table in my DB questionnaire_self that contains the answers of a survey.
Each item of this table has a foreign key user_id referred to id in the table user
What is the query to filter the users (from table user) who do not answer a survey yet, i.e., their id's are not in questionnaire_self.
Thanks.
select * from user where id not in (select user_id from questionnaire_self)