Reputation: 219
I have a table with column "paird" that is a 15 digit interger. I need a SQL expression to find all the rows that paird starts with "38"
I tired the following but it failed
SELECT * FROM table WHERE paird LIKE "38%"
any suggestions?
Upvotes: 0
Views: 2519
Reputation: 1038
You need to convert number to string first before using the LIKE operator. See below for the example using sql-server:
SELECT *
FROM table
WHERE
LTRIM(STR(Paired, 15, 0)) LIKE '38%'
Upvotes: 1
Reputation: 257
if i correct understand you, your problem is double quotes ", you need to replace on this one '
expl
select * from Table1 where Id like '1%' when i write "1%" i got the error
UPD. i try with long id and string still work in both ways
Upvotes: 2
Reputation: 143
What you are trying works with strings. If you have a 15 digit integer column (and it is always 15 digits), you could try the following:
SELECT * FROM table WHERE floor(paird/10000000000000) = 38;
Upvotes: 2