2014-12-12 2 views
0

내가 MYSQL 테이블을 불렀다 "등록"나는 열을 attachment_id 식 (33)과 출력 다른 행가 일치하는 경우 행을 얻을 필요가MYSQL 간단한 쿼리 - 필요 연합 대안

id license   price  attachment_id (maps back to the same table) 
33 Description A  10   35 
34 Description B  15   0 
35 Description C  18   0 
36 Description D  5    37 
37 Description E  10   0 

동일한 테이블에 "id"열이 있습니다.

그래서, 출력은 다음과 같아야합니다

id license   price  attachment_id (maps back to the same table) 
33 Description A  10   35 
35 Description C  18   0 

하는 방법은 UNION없이이 작업을 수행 할 수 있습니까?

답변

1

가능한 : 그것을했다

select * from registrations where 
id = 33 or id = (select attachment_id from resgistrations where id = 33) 
+0

감사합니다! – eddiejoeP