mysql - Two different values from same column as seperate columns return same results -
i have query make 2 values 1 column 2 seperate columns each has different values. query have returns same values both of these columns. need different values each. first 1 'labor intensity' returns results of 'requirements id' , 1 gets it's correct values.
i have marked 2 columns * before them.
select document.id api_id, document.name name, document.description description, document.documentkey document_key, docs.sequence sequence, documentcustomfieldvalue.documentid document_id, *max(case when documenttypefielddefinition.label = 'labor intensity' textvalue else null end) darbietilpiba, *max(case when documenttypefielddefinition.label = 'requirements id' textvalue else null end) prasibas_id, document join (select doc.id, doc.name, dn.sequence, dn.globalsortorder document doc, documentnode dn doc.projectid = 20249 -- report_projectid , dn.scopeid = 5 , dn.refid = doc.id , dn.baselineid null , dn.sequence '2%') docs on docs.id = document.id join project on document.projectid= project.id left join documentcustomfieldvalue on documentcustomfieldvalue.documentid = document.id left join documenttype on document.documenttypeid = documenttype.id left join documenttypefielddefinition on documenttype.id = documenttypefielddefinition.documenttypeid left join documentfield on documenttypefielddefinition.documentfieldid = documentfield.id left join userbase on documentcustomfieldvalue.textvalue = userbase.id document.projectid = project.id , document.active = 't' , documenttypefielddefinition.label in ('labor intensity','requirements id') group docs.sequence order docs.globalsortorder
what error makes value duplicate? if leave 'labor intensity' in statement, still gives me 'requirements id' values 'labor intensity' values.
if can't understand something, please ask me clarify something. thank you!
i figured out wrong. 1 left join wrong , needed additional setting.
current left joins working.
left join documenttype on document.documenttypeid = documenttype.id left join documenttypefielddefinition on documenttype.id = documenttypefielddefinition.documenttypeid left join documentfield on documenttypefielddefinition.documentfieldid = documentfield.id left join documentcustomfieldvalue on document.id = documentcustomfieldvalue.documentid , documentfield.id = documentcustomfieldvalue.fieldid left join userbase on documentcustomfieldvalue.textvalue = userbase.id
Comments
Post a Comment