0

Can someone tell me why this query isn’t working please?

$result = $connect->query( “SELECT * 
                            FROM DBdata 
                            WHERE catc !=‘121’ 
                            AND description LIKE ‘%$strm%’ 
                            OR ttl LIKE ‘%$strm%’ 
                            AND active = 1” );

THE PROBLEM - It IS LISTING ‘catc’ that = 121

I want the result it is giving, but don't want the catc items that equal 121

Thanks!

1 Answers1

2

Your OR is likely what's messing things up.

SELECT * FROM HWpix
    WHERE catc !='121'
    AND 
      (description LIKE '%$strm%'
       OR ttl LIKE '%$strm%')
    AND active = 1
ceejayoz
  • 176,543
  • 40
  • 303
  • 368