Queries

De wiki
Revisión a fecha de 12:41 6 oct 2014; Rmarimon (Discusión | contribuciones)

(dif) ← Revisión anterior | Revisión actual (dif) | Revisión siguiente → (dif)
Saltar a: navegación, buscar

Todas las notas y tareas

Notas

SELECT
    Thingy.createdOn AS noteCreatedOn,
    Thingy.createdBy AS noteCreatedBy,
    Note.description AS noteDescription,
    COALESCE(Contact.name, TRIM(CONCAT(Contact.firstName,' ',Contact.lastName))) AS noteReferenceContact  
FROM 
    Note JOIN Thingy ON Note.id = Thingy.id
         JOIN ThingyRelation ON Note.id = ThingyRelation.fromId AND ThingyRelation.code = '@' 
         JOIN Contact ON ThingyRelation.toId = Contact.id

Tareas

SELECT
    Thingy.createdOn AS taskCreatedOn,
    Thingy.createdBy AS taskCreatedBy,
    Task.due AS taskDue,
    Task.completed AS taskCompleted,
    Task.supervised AS taskSupervised,
    Task.description AS noteDescription,
    COALESCE(Contact.name, TRIM(CONCAT(Contact.firstName,' ',Contact.lastName))) AS noteReferenceContact
FROM 
    Task JOIN Thingy ON Task.id = Thingy.id
         JOIN ThingyRelation ON Task.id = ThingyRelation.fromId AND ThingyRelation.code = '@' 
         JOIN Contact ON ThingyRelation.toId = Contact.id