use strict; use warnings; use SQL::Builder::Select; my $select = new SQL::Builder::Select; $select->column( '*' ) ->table( 'main' ) ->where_ne_or( 'col1' ) ->where_eq_and( 'col1', 'col2' ) ->where_logic( 'a and o') ->order_by( 'col1' ) ->limit_value( 10 ) ->limit_offset( 20 ) ->debug( 1 ); print $select->return(); #### DEBUG: logic broken up 'a ', 'AND', ' o' DEBUG: joining AND - 'col1 = ?', 'col2 = ?' DEBUG: no need to join 'col1 != ?' DEBUG: joining AND - '(col1 = ?) AND (col2 = ?)', 'col1 != ?' DEBUG: sql SELECT * FROM main WHERE ((col1 = ?) AND (col2 = ?)) AND (col1 != ?) ORDER BY col1 LIMIT 20, 10