This query:
SELECT substr(d.title,0,7)
FROM orders_total d, orders o
WHERE d.orders_id = o.orders_id
Gives me this error:
#1064 - 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 '( d . title , '0' , '7' ) from orders_total d开发者_JAVA技巧 , orders o
It works without the substr, but I cannot get it to work with it.
From mySql documentation:
For all forms of SUBSTRING(), the position of the first character in the string from which the substring is to be extracted is reckoned as 1.
So you have to change the 0 for 1:
SELECT substr(d.title,1,7)
FROM orders_total d, orders o
WHERE d.orders_id = o.orders_id
SELECT LEFT(d.title,7) FROM orders_total d, orders o WHERE d.orders_id = o.orders_id
sbustr should be substring, and it starts on index 1, not 0
精彩评论