Answer the question
In order to leave comments, you need to log in
How is it possible to implement such a sql select?
Hello,
I experienced difficulty in building the right query, your help is really needed.
There are 2 tables - schedule and hw_10.
Actually, you need to display the hw column from hw_10,
while checking for compliance with
hw_10.subject_id = schedule.`first`,
schedule.student_id=1 (variable from php) and
hw_10.`date`='2014-11-24' (also php variable previously selected from the database)...
That's how tricky it is. So far, it has been possible to compose only on 1 subject_id
SELECT
hw_10.hw as hw
FROM schedule
LEFT JOIN hw_10 ON hw_10.subject_id = schedule.`first`
WHERE schedule.student_id = '1'
AND schedule.day = 'Monday'
AND hw_10.`date` = '2014-11-24'
Answer the question
In order to leave comments, you need to log in
LEFT JOIN hw_10 ON hw_10.subject_id IN [schedule.`first`, schedule.`second`, schedule.`third`, schedule.`fourth`, ...]
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[schedule.`first`, schedule.`second`, schedule.`third`, schedule.`fourth`] ' at line
4 made wrong...
SELECT
hw_10.hw as hw
FROM schedule
LEFT JOIN hw_10 ON hw_10.subject_id IN [schedule.`first`, schedule.`second`, schedule.`third`, schedule.`fourth`]
WHERE schedule.student_id = '1'
AND schedule.day = 'Monday'
AND hw_10.`date` = '2014-11-24'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question