user1255357
user1255357

Reputation: 25

Select query result based on the difference of a "quantity" in same column of two tables

table 1:

emp_id  course_id
 ______  _________
12345      4
23455      5
67890      6

table 2:

course_id  course_name
_________  ___________
   1        English
   2        Mathematics
   3        Science
   4        G.K.
   5        c++
   6        JSP
   7        ASP

REQUIRED TABLE table 3:

course_id  course_name
_________  ___________
   1        English
   2        Mathematics
   3        Science
   7        ASP

how to print table 3 in MySQL while considering difference of course_id from table 1 and table 2. (table2.course_id - table1.course_id)

Upvotes: 0

Views: 55

Answers (1)

juergen d
juergen d

Reputation: 204746

select course_id, course_name
from table2
where course_id not in (select course_id from table1)

Upvotes: 1

Related Questions