2
2つのテーブルがあります。最初のデータは、カテゴリに基づく最初のデータと2番目のメタデータです。データ内の列に基づく条件
table1
id, category1, category2, custom1, custom2, custom3...
table2
category1, category2, denom, field
例:表1にフィールド我々はメタデータを持っているtable2のポイントで
table1
AAAAA, Car, Compact, Red, Automatic, 150bhp
table2
Car, Compact, Color, custom1
'フィールド' 列。
今私がやってみたいのは、何とかsqlの 'field'列の値を列として使用することです。
select * from table1
where table1.category1 = 'Car'
and table1.category2 = 'Compact'
and table1.category1 = table2.category1
and table1.category2 = table2.category2
and table2.denom = 'Color'
and table1.(value of table2.field) = 'Red'
これは単一のSQL文で実行できますか?
であなたの答えをありがとう
を置き換えることができ、これはあなたがいる場合、クエリを編集する必要がありますよう列が表示されている必要はありませんでした何かを期待していました列は将来追加されます。しかし、これは動作するはずです:) – Mikael