I have two tables, how to show data if not exist in tbsale table?
Asked
Active
Viewed 182 times
0

Bartłomiej Semańczyk
- 59,234
- 49
- 233
- 358

Abu Ayyub
- 401
- 4
- 14
-
1Have you tried anything so far ? – PaulF Feb 26 '16 at 10:09
-
im just newbie, please help me – Abu Ayyub Feb 26 '16 at 10:10
-
2You should not treat SO as a code writing service - you should at least try searching first - a quick google search for _mysql query to find records in one table not in another_ just now came up with this as the top entry : http://stackoverflow.com/questions/367863/sql-find-records-from-one-table-which-dont-exist-in-another & this as second : http://stackoverflow.com/questions/11767565/mysql-select-rows-from-a-table-that-are-not-in-another You get better response on SO if you show you have put some effort in yourself. – PaulF Feb 26 '16 at 10:12
-
thanks so much @PaulF – Abu Ayyub Feb 26 '16 at 10:23
2 Answers
0
You can use EXPECT for this in SQL:
SELECT EmployeeID,Employee_Name
FROM TBEmployee
EXCEPT
SELECT TBSalary.EmployeeID,Employee_Name
FROM TBSalary
INNER JOIN TBEmployee ON TBEmployee.EmployeeID=TBSalary.EmployeeID

Binaya Shrestha
- 440
- 3
- 12

SadikAli
- 594
- 1
- 4
- 21
-
EXCEPT op is using MySQL (if tag is correct) which does not have that operator. – PaulF Feb 26 '16 at 10:52
0
Try this query:
SELECT Employ_Id, Employ_Name
FROM tbemploy
WHERE tbemploy.Employ_Id NOT IN (SELECT Employ_Id FROM tbsale)

Binaya Shrestha
- 440
- 3
- 12