Select Distinct

Select Distinct

mRendermRender Posts: 151Questions: 26Answers: 13

My question is very straightforward, and I can't seem to find a discussion topic if someone has already posted about this yet.

I need to select a distinct PRID from the following:

$data = Editor::inst( $db, 'tbl_PDActionLog', 'ID' )
    ->field(
        Field::inst( 'tbl_PDActionLog.LID' ),
        Field::inst( 'tbl_PDActionLog.PRID' ),
        Field::inst( 'tbl_PDActionLog.CompleteDate' ),
        Field::inst( 'tbl_PDActionLog.Content' )
    )
    ->where( 'tbl_PDActionLog.LID', $LID, '=' )
    ->process($_POST)
    ->data();

What would be the best way about doing that?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,760Questions: 1Answers: 10,510 Site admin
    Answer ✓

    You would need to use a custom query for that at the moment. There is no distinct option in Editor each each row will already be distinct by the fact that it has its own unique primary key value.

    For example, what would happen if you have two rows which had PRID of 0001 (or whatever) but they had different content and different complete dates - should both be updated with the edited data, or just one?

    Now having said that, it is possible to select just one of the rows - perhaps the one with the latest complete date. The Editor manual has information on how you could do that with a sub-select.

    Allan

This discussion has been closed.