JOIN
문을 여러 테이블의 선택 값에 사용하려고하면 ORA-00932: inconsistent datatypes: expected - got BLOB
이 표시됩니다. 는 IS 다음 내 오라클 SQL 코드 :ORA-00932 : 일치하지 않는 데이터 유형 : 예상 됨 - 다른 테이블을 조인 할 때 BLOB가 발생했습니다.
questions
:
id int not null,
question varchar(999),
details varchar(1000) not null,
author int not null,
datetime varchar(999)
answers
id int not null, primary key(id),
question int not null,
answer blob not null,
usr int not null,
ansdatetime int not null
questions_tags
SELECT
MAX(questions.id),
MAX(questions.question),
MAX(questions.author),
MAX(questions.datetime),
MAX(answers.answer),
MAX(answers.usr),
MAX(answers.ansdatetime)
FROM
questions
LEFT JOIN
answers ON
questions.id = answers.question
LEFT JOIN
questions_tags ON
questions.id = questions_tags.question_id
WHERE
questions_tags.tag_id IN (1,2,3,4,5,6)
GROUP BY
questions.id, answers.id
ORDER BY
questions.datetime DESC
다음 세 가지 테이블에 대한 테이블 구조
id INT NOT NULL,
question_id INT NOT NULL,
tag_id INT NOT NULL,
PRIMARY KEY(id)
여기에 무슨 문제가 있습니까?
내 생각에 BLOB 값에는 MAX가 정의되어 있지 않아서 MAX (answers.answer)가 실패합니다. 어쨌든 각 열의 MAX를 개별적으로 취하는 것이 아니라 실제로 하위 쿼리가 필요합니다. 또는 단지 선택된 ID를 표시하지 않고 GROUP BY에 모든 선택된 열을 넣을 수 있습니다. – IMSoP
'answers.answer'는'blob'입니다. 'blob'에서'MAX'를 할 수 없습니다. 그러나 각각의 개별 열에 대해 'MAX'를 수행하기를 원하지는 않습니다. 일반적으로 여러 행에 대해 데이터를 함께 결합합니다. 특정 질문에 대한 가장 최근의 답변을 정말로 받고 싶습니까? –
@JustinCave 예, 답변이있는 경우 반환되는 질문에 대해 가장 최근의 답변을 받아야합니다. – DemCodeLines