Reputation: 2698
Does anyone nows how to replace null values with another column in another table in SQLite
say this select statement
SELECT t1._id , t1.name , t2.img FROM
t1 JOIN t2 on (t1._id = t2._id);
if t1._id == null
i want to return t2._id
in that column
Upvotes: 2
Views: 5832
Reputation: 2991
see this: http://sqlite.awardspace.info/syntax/sqlitepg09.htm
What you want is a case statement
SELECT case when t1._id is null then t2._id else t1._id end as id, t1.name , t2.img FROM
t1 JOIN t2 on (t1._id = t2._id);
Upvotes: 3