У меня есть две таблицы: donaTypes
и fullInfo
.
fullInfo
:
id funddesc giftamt giftdate
001 annual fund 50.00 2010-03-09
223 alumni fund 25.00 2009-03-06
334 capital exp 100.00 2011-09-27
... ... ... ...
donaTypes
:
id donaType
1 annual fund
2 capital exp
3 alumni fund
I 'я пытаюсь найти совпадение, где fullInfo.funddesc = donaTypes.donaType
, с надеждой вставить число donaTypes.id
в таблицу fullInfo
.Вот мой код, но я просто получаю пустой ответ (без ошибок):
SELECT st1.funddesc, st2.donatype
FROM
(select t1.funddesc
from fullInfo as t1) st1
inner join
(select t2.donatype
from donatTypes as t2) st2
on trim(st1.funddesc) like trim(st2.donaType)
;
Я также пытался:
SELECT t1.funddesc, t2.donatype
FROM fullInfo as t1,
donatTypes as t2
where trim(t1.funddesc) = trim(t2.donatype);
В идеале, я бы хотел, чтобы fullInfo
выглядел так:
fullInfo
:
id funddesc giftamt giftdate
001 1 50.00 2010-03-09
223 3 25.00 2009-03-06
334 2 100.00 2011-09-27
... ... ... ...