| |

VerySource

 Forgot password?
 Register
Search
View: 949|Reply: 4

Ask a SQL query for fuzzy queries

[Copy link]

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-22 18:40:01
| Show all posts |Read mode
The function I implemented is this:
There are two types in total. The first type is, for example, that I want to find a record with a hundred-digit number 1 in the table. It must be in the hundred-digits and one. The database table itself contains three-digit records. The result is something like 135,178,176,1 **.
The other type is not divided into digits, as long as one of the three digits is eligible
For example: 178,651,216, etc.
Reply

Use magic Report

1

Threads

21

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-2-4 17:30:02
| Show all posts
1. select * from tb1 where (column1-100) between 0 and 99

2.SELECT *
FROM tb1
WHERE (CAST (column1 AS varchar) LIKE '% 1%')
Reply

Use magic Report

2

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-5 02:45:01
| Show all posts
r can't understand (column1-100) What does this mean?
There is also this CAST (column1 AS varchar)? Conversion?
Reply

Use magic Report

1

Threads

21

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 Great Britain

Post time: 2020-2-6 14:45:02
| Show all posts
column1 is the name of that column, I do n’t know your column name, so use column1 instead
1. What I said is that the condition I choose is that the number of column1-100 is between 0 and 99, that is, the hundreds place is 1.

2CAST (column1 AS varchar) This is a type conversion. I guess your database column should be a numeric type. We need to convert it into a character type. You need to convert it to a character type first, and then see if there is a 1 This character

Specifically, look at your t-sql online help. There are related examples above.
Reply

Use magic Report

0

Threads

21

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-2-12 17:00:01
| Show all posts
The first question on the third floor is wrong, it should not be between 100 and 99
The landlord said that the thousandth is only 1. The number does not mean that the thousandth is over.
use:
where mid (right (cast column1 as nvarchar, 3), 1,1) = ‘1’
Write it like this!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list