1

would appreciate some help. MySQL is ignoring that I ask just for rows where the invoicenumber starts with some characters. No error message. I just get all invoices as I have asked for.

I added OR 'orders_billing'.'rechnungsnummer' LIKE 'xy%' OR 'orders_billing'.'rechnungsnummer' LIKE 'ab%'

And this part does not work. Could anybody give me a hint, please?

SELECT     "orders_billing"."billing_id",
                            "orders_total_local"."orders_id",
                            "orders_billing"."rechnungsnummer",
                            "orders_total_local"."value" as versandkosten,
                            "orders_billing"."rechnung_crdate",
                            "orders_billing"."billing_company",
                            "orders_billing"."billing_address_id" as customers_id,
                            "orders_billing"."billing_name",
                            "orders_billing"."billing_country",
                            "orders_billing"."delivery_country",
                            "orders_billing"."rechnung_pdf",
                            "orders_products_local"."final_price",
                            "orders_products_local"."products_tax",
                            "orders_local"."currency"
                    FROM    "orders_billing"
                    LEFT JOIN("orders_products_local","orders_local","orders_total_local")
                            ON( "orders_products_local"."orders_id" = "orders_billing"."orders_id" AND 
                                "orders_local"."orders_id"          = "orders_billing"."orders_id" AND 
                                "orders_total_local"."orders_id"    = "orders_billing"."orders_id" 
                                ) 
                    WHERE "billing_id" > '23' && "billing_id" < '27'
                    OR "orders_total_local"."class"    = 'ot_shipping' 
                    OR "orders_billing"."rechnungsnummer" LIKE 'ABC%' 
                    OR "orders_billing"."rechnungsnummer" LIKE 'XYZ%' 
Dharman
  • 30,962
  • 25
  • 85
  • 135
Jan
  • 23
  • 5
  • Learn about operator precedence `WHERE ("billing_id" > '23' && "billing_id" < '27' OR "orders_total_local"."class" = 'ot_shipping' ) AND ("orders_billing"."rechnungsnummer" LIKE 'ABC%' OR "orders_billing"."rechnungsnummer" LIKE 'XYZ%')` First OR could be AND its hard to tell – Mihai Apr 26 '16 at 16:39
  • This is absolutely right and was the solution to my problem. (Thank You!!!) – Jan Apr 26 '16 at 17:20

1 Answers1

0

Try this,

WHERE "billing_id" > '23' AND "billing_id" < '27'
                    OR ("orders_total_local"."class"    = 'ot_shipping') 
                    OR ("orders_billing"."rechnungsnummer" LIKE 'ABC%' )
                    OR ("orders_billing"."rechnungsnummer" LIKE 'XYZ%')

Another way,

WHERE "billing_id" > '23' && "billing_id" < '27'
                        || ("orders_total_local"."class"    = 'ot_shipping') 
                        || ("orders_billing"."rechnungsnummer" LIKE 'ABC%' )
                        || ("orders_billing"."rechnungsnummer" LIKE 'XYZ%')
Sagar R
  • 595
  • 3
  • 14