where clause doesn't work for less and bigger

where clause doesn't work for less and bigger

erickmterickmt Posts: 15Questions: 3Answers: 1

I'm trying to compare 2 columns in where clause. The page work but the clause doesn't.

->where( 'produto.quantidade_estoque', 'produto.alerta_maximo', '<')

Answers

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin

    Use:

    ->where( function ( $q ) {
      $q->where( 'produto.quantidade_estoque', 'produto.alerta_maximo', '<', false)
    } )
    

    The condition documentation is available here and explains why the false is required in an anonymous function. Basically if you don't add that false it will treat the second parameter as a string, not a column name.

    Allan

  • erickmterickmt Posts: 15Questions: 3Answers: 1
    edited November 2017

    Thank you to answer but it didn't work to me

    "DataTables warning: table id=estoque_maximo - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1"

  • allanallan Posts: 63,461Questions: 1Answers: 10,466 Site admin

    Sorry - it looks like I'm missing a semi-colon at the end of the line in the anonymous function. The error returned by the server should state that.

    Allan

  • erickmterickmt Posts: 15Questions: 3Answers: 1

    Perfect! Thank you!

This discussion has been closed.