SQL Query problem: string comparision

VeRiTo
10-26-2004, 11:21 AM
I have a problem with this query:


SELECT Article,ArtName
FROM Articles
WHERE State=1 AND
ArtName LIKE 'TELEVISION GRUNDIG%'
ORDER BY ArtName


It should have returned is
Article -> 10
ArtName -> 'TELEVISION GRUNDIG 14 inches'

It just didnt return any row.

So i tried to use EQUAL operator:

SELECT Article,ArtName
FROM Articles
WHERE State=1 AND
ArtName = 'TELEVISION GRUNDIG 14 inches'
ORDER BY ArtName

And it doesnt return any row either!!!
I am sure the string i am comparing with is exactly the same stored in field!
Any ideas?
Thanks in advance.

VeRiTo
10-26-2004, 11:24 AM
Oh, something interesting:
If the string's lenght is minor to 15 it works great... :(

rjm
10-26-2004, 12:05 PM
I have a problem with this query:


SELECT Article,ArtName
FROM Articles
WHERE State=1 AND
ArtName LIKE 'TELEVISION GRUNDIG%'
ORDER BY ArtName


It should have returned is
Article -> 10
ArtName -> 'TELEVISION GRUNDIG 14 inches'

It just didnt return any row.

So i tried to use EQUAL operator:

SELECT Article,ArtName
FROM Articles
WHERE State=1 AND
ArtName = 'TELEVISION GRUNDIG 14 inches'
ORDER BY ArtName

And it doesnt return any row either!!!
I am sure the string i am comparing with is exactly the same stored in field!
Any ideas?
Thanks in advance.

What database are you using?
What datatype is your ArtName field?
If it's a memo field, then you'll have to use the CAST statement.
The length of the string shouldn't make a difference on your LIKE statement if the datatype is text or character.

VeRiTo
10-26-2004, 12:19 PM
I am using Microsoft SQL Server 2000.
ArtName is varchar(30)

With this query:

Select distinct ArtName,Articulo
From Articles
Where State=1 And
ArtName LIKE 'BAG P0LY s20(R/%'
Order by ArtName


i get this:
ArtName -> BAG P0LY S20(R/V) HDPE FOAM T0.5x970x900
Articulo -> 50

With this query:

Select distinct ArtName,Article
From Articles
Where State=1 And
ArtName LIKE 'BAG P0LY S20(R/V) HDPE FOAM T0.5x970x900%'
Order by ArtName


i get nothing....

rjm
10-26-2004, 12:29 PM
I've used DISTINCTROW, but not distinct.
Is distinct a fieldname?

rjm
10-26-2004, 12:43 PM
Try using the * for the wildcard character and see if that gives you different results.

loquin
10-26-2004, 02:23 PM
Also, check the value of your State field.

MKoslof
10-29-2004, 05:38 PM
In addition, are there any additional spaces in your string. If you are comparing against large strings with some complex characters, try wrapping it in RTRIM and LTRIM.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum