What currently happens is it just selects students from CA and students who like to skateboard. I need it to return only students who are both from CA and play soccer.
Asked
Active
Viewed 67 times
2 Answers
0
SELECT *
FROM schooldata a
INNER JOIN studentinfo b
ON b.schooldata_id = a.id
WHERE a.state = "ca"
AND ( activity = "soccer"
OR activity = "skateboard" )
You will have to do inner join based on lastname and firstname column ex:-b.lastname=a.lastname and b.firstname=a.firstname . ideally you should be maintaining primary key column of type integer in schooldata table and its foreign key reference in studentinfo and join based on those columns.

supravi
- 59
- 5
-1
You should use join clauses. And I think base on your question. Inner Join is the best clause you should use.
SELECT column_name(s) FROM table1 INNER JOIN table2 ON table1.column_name = table2.column_name;