LOCATE and INSTR don't work in SQL
-
I have a mysql query that works fine using phpMyAdmin. When I try and run it as a sql command in Abase, the following breaks the query:
(IF(LOCATE('Boat Type : J/29',
ps_order_detail.
product_name)> 0, 'J/29' , 'J/30'))'Class',
This also does not work:
(IF(INSTR('Boat Type : J/29',
ps_order_detail.
product_name)> 0, 'J/29' , 'J/30'))'Class',
What I do is look for a particular string in a field and write a shorter version in the display output. Is there a different syntax I should be using with Abase?
The full error is pasted below.
#1. [abase sql="”SELECT(CONCAT(
ps_customer.
firstname`,’”]
Fatal Error (1384)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘”SELECT(CONCAT(ps_customer
.firstname
,’’ at line 1`This is the full query:
[abase sql="SELECT(CONCAT(
ps_customer.
firstname,' ',
ps_customer.
lastname))'Skipper', (
ps_customer.boat)'Boat', (
ps_customer.hull)'Hull', (
ps_customer.sailnum)'Sail', (IF(INSTR('Boat Type : J/29',
ps_order_detail.product_name)> 0, 'J/29' , 'J/30'))'Class', (
ps_customer.
email)'Email' , (
ps_orders.id_order)'Order', (
ps_order_detail.product_reference)'Ref', (
ps_orders.total_paid)'Paid' FROM
ps_ordersINNER JOIN
ps_customerON
ps_customer.
id_customer=
ps_orders.
id_customerINNER JOIN
ps_order_detailON
ps_order_detail.
id_order=
ps_orders.
id_orderINNER JOIN
ps_order_historyON
ps_order_history.
id_order=
ps_orders.
id_orderWHERE (
ps_order_detail.
product_reference='2014SNE') AND (
ps_orders.payment LIKE('PayPal%') AND
ps_orders.valid = 1 OR (
ps_orders.payment = 'Check' AND
ps_orders.valid = 1 ) OR
ps_orders.payment = 'Free Order' AND
ps_orders.valid = 1) AND
ps_order_history.id_order_state != 1 ORDER BY Class,
ps_orders.id_order"]
- The topic ‘LOCATE and INSTR don't work in SQL’ is closed to new replies.