mysql SUBSTR() problem
Nice easy one fo开发者_开发百科r this morning.
Ok, here's my little sql
statement
SELECT SUBSTR(quote,1,20) FROM b_quotes WHERE id='74'
This is returning an empty result which is confusing because if I call upon any other part of that record (the customers email address for example) it returns it perfectly. I've tried variations and it always seems to be the SUBSTR part that is failing.
could anyone shed some light on this?
Thanks Shane
Since you haven't indicated which data type is used for the quote column, try this:
SELECT SUBSTR(CAST(quote as CHAR),1,20) FROM b_quotes WHERE id='74'
Try SELECT SUBSTR(quote,1,20) AS q FROM b_quotes WHERE id='74'
What's the datatype of the quote
column? If it's a CHAR or VARCHAR, what's its length? What code are you using to access the data returned from the database?
Your SQL statement is correct, so if you want to avoid workarounds and just want to know why your query doesn't seem to work (as you asked) you have to research problems in your application code.
精彩评论