Reputation: 495
[TABLE1]
+----------+-------------------+
| USERNAME | POST |
+----------+-------------------+
| Bob | 'Hi There' |
| Jack | 'Hello' |
| Bob | 'Today is Monday' |
+----------+-------------------+
[TABLE2]
+----------+-----------+
| USERNAME | FOLLOWING |
+----------+-----------+
| Mike | Jack |
| Jack | Bob |
| Bob | Jack |
| Jack | Mike |
+----------+-----------+
I am using this join statement:
SELECT t1.* FROM TABLE1 t1 INNER JOIN table2 t2
ON t1.username = t2.following AND t2.username = 'jack';
This works, but in addition to returning these results, i also want to add "OR t1.USERNAME = 'jack';
and then another OR.. is there a way to do the join but then also an OR statement
Upvotes: 0
Views: 68
Reputation: 13700
Simplified method
SELECT t1.* FROM TABLE1 t1
INNER JOIN table2 t2 ON t1.username = t2.following
where 'jack' in (t1.USERNAME,t2.username)
Upvotes: 0
Reputation: 1079
yes you can do that like
SELECT t1.* FROM TABLE1 t1 INNER JOIN table2 t2 ont1.colName1=t2.Colname2 where colname ='value' or colname='vaue1' or colname='value';
Upvotes: 0
Reputation: 29091
You should specify multiple OR conditions inside brackets:
SELECT t1.*
FROM TABLE1 t1
INNER JOIN table2 t2
ON t1.username = t2.following
AND (t2.username = 'jack' OR t2.username = 'John' OR t2.username = 'Tom');
Upvotes: 1
Reputation: 204766
Put that conditions in a where
clause
SELECT t1.* FROM TABLE1 t1
INNER JOIN table2 t2 ON t1.username = t2.following
where t2.username = 'jack'
OR t1.USERNAME = 'jack'
Upvotes: 1