Here is my table structure:
Table 1
id | question | posted_id
Table 2
id | username | email
Table 3
id | reader_id | quote_id
I want to fetch those question which are not read by particular user.I also want email from table2 in result set. So I created Below query that join my two table1 and table2. My query:
SELECT table1.id,table1.question,table1.posted_id,table2.email
FROM table1,table2
WHERE table1.post_id = table.id;
How to fix a left join on table 3 for filter the records Because I need questions which are not read by particular user.
I am not sure which user field you are trying to match against, i have taken email, Also this will only give matching records, Try
SELECT T1.*,T2.email
FROM Table1 AS T1
INNER JOIN Table2 AS T2 ON T2.quote_id = T1.id
INNER JOIN Table3 AS T3 ON T3.reader_id = T2.id
WHERE T2.email='some_mail_id'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.