Where condition

Where condition

antoniocibantoniocib Posts: 277Questions: 62Answers: 1

Hi guys i need to excute this query but where i wrong, can you help me?

SELECT * FROM `scrivania` WHERE start = "HUB" AND hub = 0 OR hub = 1
->where("start","HUB") and ("hub",0) or ("hub",1)

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,173Questions: 26Answers: 4,923
    edited September 2020 Answer ✓

    The Where docs shows how to apply multiple where conditions.

    Kevin

  • antoniocibantoniocib Posts: 277Questions: 62Answers: 1

    @kthorngren i read but dont understand how to do i try in this way but not work

        ->where( function ( $q ) {
            $q->where( function ( $r ) {
                $r->where( 'hub', '1' );
                $r->or_where(( 'hub', 0 )("start","HUB"));
            } );
        } );
    
  • antoniocibantoniocib Posts: 277Questions: 62Answers: 1

    i solved i used this:

        ->where( function ( $q ) {
            $q
                ->where( 'hub',1)
                ->or_where( function ( $r ) {
                    $r->where( 'hub', 0 );
                    $r->where( 'start', 'HUB' );
                } );
        } )
    
This discussion has been closed.