select t1.rowid as r1, t2.rowid as r2, t2.col as matchvalue from cards t1 join
(
select rowid, col1 col from cards where rowid=3 union all
select rowid, col2 from cards where rowid=3 union all
select rowid, col3 from cards where rowid=3 union all
select rowid, col4 from cards where rowid=3 union all
select rowid, col5 from cards where rowid=3 union all
select rowid, col6 from cards where rowid=3 union all
select rowid, col7 from cards where rowid=3 union all
select rowid, col8 from cards where rowid=3
) t2
on t2.col in (t1.col1, t1.col2, t1.col3, t1.col4, t1.col5, t1.col6, t1.col7, t1.col8)
and t1.rowid = 1