Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LIKE with WHERE

Status
Not open for further replies.

crxcte1

Programmer
May 22, 2003
74
US
The below works but only on the first number. The table has the column data type as nvarchar size 13, also tried varchar and float, all types return the same data or lack of. Running MS SQL 2000 STD Ed. SP3.

the sql:

this works
select a, b, c from table where c like '6%';

but this does not
select a, b, c from table where c like '6625%';

There are 13 numbers in the field.

Was able to format the query like the following and it worked;

SELECT *
FROM table
WHERE (C LIKE '6%6%2%5%0%')

the return of numbers started with 66250....

Any ideas?

 
Maybe you can try

SELECT *
FROM a
WHERE id in (6,66,662,6625,66250)

If you want 6,66,662,6625,66250
 
Maybe you can try

SELECT *
FROM a
WHERE id in (6,66,662,6625,66250)

If you want 6,66,662,6625,66250

If this is not you want,please be more specific
 
There are 13 number in the field. The "LIKE '66%'" should work but doesn't.
 
Returns column heading an empty cells. Doesn't return any errors.
 
Check to make sure that you don't have a space between the numbers and the wildcard (ie. 66 %).

-SQLBill
 
Thanks for the input Bill, I verified the possible type-Os before posting. Something about the SQL is not processing the query correctly, I guess know one has seen this bug in the STD edition?


 
Your query string works fine on my Standard edition 2000. But given the query you said worked
(SELECT *
FROM table
WHERE (C LIKE '6%6%2%5%0%'))
I wonder if there are spaces in your data records between the numbers in the field. So instead of 66250 it shows 6 6 2 5 0?
 
Checked the spaces in the data and there is none. There are 13 numbers in a column size of 13.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top