1

別の列のデータに基づいて、ある列で何かを選択する方法を探しています。私は2つのテーブルを持っています:

input_table - has a column called "year_of_birth"
result_table - has a column called "notes" 

ご覧のとおり、「メモ」列には、「1980」のような年が含まれている場合があります。メモ フィールドに year_of_birth フィールドと一致する行を選択できるようにする必要があります。私はこれまでに次のように自分の声明を書いています。

select inp.year_of_birth, res.notes, res.result
from order_input inp join order_result res on inp.order_id = res.order_id 
where res.result !='no match'
and res.notes like '%' + inp.year_of_birth + '%'

現在、「varchar 値 '%' をデータ型 int に変換するときに変換に失敗しました」というエラーが表示されます。これを使用している同様のステートメントがあるため、何が間違っているのかわかりません動作する文字列のタイプ...

4

2 に答える 2

2

代わりにCONCATを使用する必要があります+

res.notes like CONCAT('%', inp.year_of_birth, '%')
于 2013-04-29T21:40:24.453 に答える
0

これを試して:

select inp.year_of_birth, res.notes, res.result from order_input as inp join order_resultas res on inp.order_id = res.order_id where res.result <> 'no match' and res.notes like CONCAT('%', inp.year_of_birth, '%')
于 2013-04-29T21:44:06.950 に答える