나는 이주 디렉토리 아래에 두 개의 클래스가 있습니다. ruby activerecord 쿼리를 사용하여 단일 열을 선택하는 방법
class1
create_table :table1 do |t|
t.integer :name
end
end
class2
create_table :table2 do |t|
t.integer :table1_id
t.integer :name
t.text :value
end
end
나는 조건 table2.table1_id = "1"과 table2.name = "A"
어떻게 루비에서 이것을 쓰기를 사용하여 표 2에서 유일한 값 열을 가져올까요? 결과로 텍스트 값을 가져 오려고합니다. 당신은 다음과 같은 쿼리를 적용하여 기록을 가져 오지 수
select value from table2 where table1_id = 1 and name = 'A';