user3546207
user3546207

Reputation: 20

how to create virtual table for inserting null value in mysql

 employee
id  name
1   mark
2   Clark
3   Johnson 
4   peter


emp_salary

empid  sal
 1     2000
 2     4000
 2     null
 4     6000
 5     null

I need employee name whose salary is null...and also i need show 5000 salary where salary is null, without inserting value in emp_salary table

I tried

Select  e.name,e.empid,e.salary 
from table employee e inner join emp_salary em on e.id=em.empid  
where em.salary=null

but this query is not working

I need to select null value and show 5000 on null value without affecting table

Upvotes: 0

Views: 71

Answers (1)

Val
Val

Reputation: 413

Select e.name,e.empid,'5000' salary 
from table employee e inner join emp_salary em on e.id=em.empid
where em.salary is null

check for null with "IS NULL" not "=NULL"

This will show all employees whose salary is null, but your select will show the "salary" as 5000

Upvotes: 1

Related Questions