| |

VerySource

 Forgot password?
 Register
Search
View: 818|Reply: 9

How to filter out the percent sign of sql statement?

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-21 18:40:01
| Show all posts |Read mode
Everyone knows that percent signs ("%") are wildcard characters in SQL statements.

Now there is a TextBox input box on the screen, and the program searches the database according to the value of this input box as a query condition.
At this time, if you enter a percent sign ("%"), you do not want to retrieve all the data. So you need to filter it out.

Masters please help, is there a way to filter out the percent sign ("%")?

In addition, if there is data with percent sign ("%") in the database, entering the percent sign ("%") should be able to find out that piece of data.

Wait for the answer online!
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-31 15:54:01
| Show all posts
Tried with escape characters
TextBox.text = Replace (TextBox.text, "%", "\%")
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-1 10:27:01
| Show all posts
Can not do it
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-1 14:09:02
| Show all posts
TextBox.text = Replace (TextBox.text, "%", "[%]")
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-1 14:45:01
| Show all posts
Special characters are treated with left and right brackets
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-2-5 03:15:02
| Show all posts
Right

Square bracket filtering is only effective in the DataView's RowFilter, right?

I'm talking about how to filter percent signs in SQL statements.
Reply

Use magic Report

1

Threads

5

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-10 21:00:01
| Show all posts
Is TextBox.text = Replace (TextBox.text, "%", "[%]")
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-18 11:15:01
| Show all posts
Halo, you try the difference between select * from table where field like 'a%' and select * from table where field like 'a [%]', actually said that SQL does not support it. . . .
Reply

Use magic Report

1

Threads

16

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-2-18 13:15:01
| Show all posts
The landlord didn't even try it and said no, depressed. . . . . . .
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-7-23 00:15:01
| Show all posts
select * from table where aa like'liu&%' escape '&'
Set the escape character.
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