SELECT * , SUBSTRING( `Reference` , (
LOCATE( "08", `Reference` ) ) AS TRACK
FROM `work`
WHERE `Reference` LIKE "%08-%"
This is giving me a syntax error. What's wrong?
|
|
0
|
|
|
|
Reply
|
Derek
|
2/7/2011 1:25:19 PM |
|
Derek Turner:
>SELECT * , SUBSTRING( `Reference` , (
>LOCATE( "08", `Reference` ) ) AS TRACK
>FROM `work`
>WHERE `Reference` LIKE "%08-%"
>
>This is giving me a syntax error. What's wrong?
The number of parentheses: 3x'(' and 2x')'
|
|
0
|
|
|
|
Reply
|
Erick
|
2/7/2011 1:34:16 PM
|
|
On 7 Feb 2011 13:25:19 GMT, Derek Turner wrote:
> SELECT * , SUBSTRING( `Reference` , (
> LOCATE( "08", `Reference` ) ) AS TRACK
> FROM `work`
> WHERE `Reference` LIKE "%08-%"
>
> This is giving me a syntax error. What's wrong?
Some hints that might help you:
Don't use backtics around identifiers. I know a whole bunch of admin
type programs do that, but they do that because they're protecting
people from being morons in the simplest way they know how. If you're
not a moron, you won't need them at all because you'll be using
SQL-standard identifiers that are not reserved words to begin with.
Using backtics to mask that only leads to confusion and pain later.
Don't use " as a quoting mark. It is also not standard and standard is
perfectly adequate to express everything you'd need to express, so using
it will only serve to cause confusion and pain further down the road.
Finally, when asking what an error is, MySQL conveniently tells you
EXACTLY where it first realized that there was a problem in the part of
the error message that reads "check the manual that corresponds to your
MySQL server version for the right syntax to use near 'point_where_the
problem_is'". That "near 'point_where_the_problem_is'" is *THE MOST
IMPORTANT PART OF THE ERROR*. If you really want fast and precise help
from people instead of getting insults and mockery, you'll post the
entire error message when you get an error message.
--
94. When arresting prisoners, my guards will not allow them to stop and
grab a useless trinket of purely sentimental value.
--Peter Anspach's list of things to do as an Evil Overlord
|
|
0
|
|
|
|
Reply
|
Peter
|
2/7/2011 1:49:53 PM
|
|
On 07-02-11 14:25, Derek Turner wrote:
> SELECT * , SUBSTRING( `Reference` , (
> LOCATE( "08", `Reference` ) ) AS TRACK
> FROM `work`
> WHERE `Reference` LIKE "%08-%"
>
> This is giving me a syntax error. What's wrong?
you have 3 times a '('
and only 2 times a ')'
--
Luuk
|
|
0
|
|
|
|
Reply
|
Luuk
|
2/7/2011 1:55:54 PM
|
|
On Mon, 07 Feb 2011 13:34:16 +0000, Erick T. Barkhuis wrote:
> Derek Turner:
>
>>SELECT * , SUBSTRING( `Reference` , ( LOCATE( "08", `Reference` ) ) AS
>>TRACK FROM `work`
>>WHERE `Reference` LIKE "%08-%"
>>
>>This is giving me a syntax error. What's wrong?
>
> The number of parentheses: 3x'(' and 2x')'
Thanks for the quick response, I looked and looked but couldn't see it :)
And now I've got the SUBSTRING syntax the right way round it even does
what I want it to do!
|
|
0
|
|
|
|
Reply
|
Derek
|
2/7/2011 2:14:23 PM
|
|
On 2/7/2011 9:14 AM, Derek Turner wrote:
> On Mon, 07 Feb 2011 13:34:16 +0000, Erick T. Barkhuis wrote:
>
>> Derek Turner:
>>
>>> SELECT * , SUBSTRING( `Reference` , ( LOCATE( "08", `Reference` ) ) AS
>>> TRACK FROM `work`
>>> WHERE `Reference` LIKE "%08-%"
>>>
>>> This is giving me a syntax error. What's wrong?
>>
>> The number of parentheses: 3x'(' and 2x')'
>
> Thanks for the quick response, I looked and looked but couldn't see it :)
>
> And now I've got the SUBSTRING syntax the right way round it even does
> what I want it to do!
The open parens in front of Reference does not have a corresponding
closing parens.
Bill B
|
|
0
|
|
|
|
Reply
|
Bill
|
2/7/2011 3:06:23 PM
|
|
|
5 Replies
165 Views
(page loaded in 0.05 seconds)
Similiar Articles: How to query when a text field is too big to convert? - comp ...Unless you got your description wrong, you also have the test backwards. To test if field_1 is a substring of field_2 select field_1 from table where not field ... Do Loop Shift Column - comp.soft-sys.sasDo Loop Shift Column - comp.soft-sys.sas select specified columns in ch. array - comp.lang.fortran ... Do Loop Shift Column - comp.soft-sys.sas extracting elements from a ... syntax error "missing ; before statement" - comp.lang.javascript ...I thought maybe it was because the wave is a number 0-9 beginning the select object? ... The bu's are 5 digits that is why the substring is 5, as I mentioned the first number ... Split full name in to first, middle, and last name - comp ...SELECT SUBSTRING_INDEX(title, ' ', 1) AS fname, SUBSTRING_INDEX(title, ' ', -1) as lname FROM mytable; This assumes you haven't stored more information in the column. Show/Hide buttons based on radio selection - comp.lang.javascript ...... 0;i<which.length;i++) { var tempobj=which.elements[i]; if (tempobj.name.substring(0,1 ... Show/Hide text and form field based on drop down selection - comp ... Dropdown and ... comp.databases.btrieve - page 9select if(substring(text,1,1)='2','#',substring(text,1,1))+ if(substring(text,2,1)='3','#',substring(text,2,1)) from test same samples text = '23','25','53' result ... Substr, but without padding - comp.lang.rexx... reasonable size for my DATA */ Do forever left = chars(tmpfile) select ... replace WITHIN file without TEMP file ... ... I want to print only the substring ... Query with NULL - comp.databases.oracle.serverHi, I have a lot of queries like below: >select * from bxat.no5 >WHERE (no0 ... field is too big to convert? - comp ..... in a table where field_1 is not a substring ... Script to count occurrences - comp.unix.programmer... grep "${ip}" data.dat |wc -l) > done I this fails if one IP address is a substring ... Then > > SQL > SELECT DISTINCT ip, COUNT(*) > FROM ip_addresses ... namelist input of multidimensional array? - comp.lang.fortran ...It seems that for F2003 (10.10.1.1) that subscripts, strides, and substring ... Selecting elements of a multidimensional matrix - comp.soft-sys ... namelist input of ... SUBSTRING (Transact-SQL)IF EXISTS (SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'npub_info') DROP TABLE npub_info; GO -- Create npub_info table in pubs database. [xsl] Selecting a substring()Hello all, I have a problem with Xalan where I am trying to convert some XML to HTML. I have an XML element from which I am trying to extract information: <data ... 7/15/2012 7:54:25 AM
|