-1

enter image description here

enter image description here

enter image description here

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.

Nick
  • 27
  • 1
  • SO is not a code writing service. You have to make some effort. See https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query – Strawberry May 02 '18 at 06:33

2 Answers2

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;