Where Priority

by Jul 27, 2015



I'm evaluting SQLYog, and I did my first query on Query builder, but I don't understand how priotity works.


I need a WHERE like this

WHERE ((((`kogest`.`documentocomercial`.`DTYPE` = 'AlbaranDeVenta')
AND ISNULL(`kogest`.`documentocomercial`.`facturado_en`))
OR ((`kogest`.`documentocomercial`.`DTYPE` = 'FacturaDeVenta')
AND ISNULL(`kogest`.`documentocomercial`.`abonado_en`)))
AND (`kogest`.`seriedocumento`.`notas` = 0)
AND (`kogest`.`detalledocumento`.`totalLinea` > 0)));

As you can see in attached screenshots, I used it as I think it's suppose to be. I mean, for the field with creteria and OR, should be solved together, but query builder does:

WHERE (`detalledocumento`.`totalLinea` >0
AND `documentocomercial`.`DTYPE` = 'AlbaranDeVenta' AND ISNULL(`facturado_en`)
AND `seriedocumento`.`notas` =0)
OR (`documentocomercial`.`DTYPE` = 'FacturaDeVenta')
AND ISNULL(`documentocomercial`.`abonado_en`));

It doesn't apply any kind of priority. Is this the normal behaviour? or something I'm doing wrong?


EDITED..to clarify, field DTYPE should be

(DTYPE='AlbaranDeVenta' AND ISNULL(`facturado_en`)) OR (DTYPE = 'FacturaDeVenta' AND ISNULL(`documentocomercial`.`abonado_en`))

I want this to be solved entirely as one block of WHERE clause