Maikel Maikel - 7 months ago 9
SQL Question

How to ignore the field that common in two tables

I have two tables

t1 t2
------------------- ---------------------
no course no equivalent
------------------- ---------------------
1 MATH 101 2 CHEM 111
2 CHEM 101
3 ENG 101


How I can write query or query with function in php language that show me courses and disappear the courses that its no common between the two tables.

likes this

output

--------------------
no course
--------------------
1 MATH 101
3 ENG 101


in the output table course number 2
( 2 CHEM 101)
do not appear in the table because its number shared between t1 and t2 .
I want like that.

Answer

Try this

SELECT * FROM t1 WHERE t1.no!=(SELECT no FROM t2)