| |

VerySource

 Forgot password?
 Register
Search
View: 1007|Reply: 5

How to write a query with a semicolon in a field

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-19 15:40:01
| Show all posts |Read mode
Excuse me, the id field of the table person holds multiple data separated by semicolons in the content, which is "123; 234; 345".
select * from person where id .....
The variable corresponding to id is 123, which is a part of the content of id.
How to write the query?
Reply

Use magic Report

0

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-26 14:27:01
| Show all posts
select * from person where charindex (id, '123')> 0
Reply

Use magic Report

0

Threads

114

Posts

69.00

Credits

Newbie

Rank: 1

Credits
69.00

 China

Post time: 2020-1-26 15:54:01
| Show all posts
select * from person where id like '% 123%'
Reply

Use magic Report

0

Threads

211

Posts

108.00

Credits

Newbie

Rank: 1

Credits
108.00

 China

Post time: 2020-1-26 17:00:02
| Show all posts
--try
select * from person where charindex ('123', id)> 0
or
select * from person where id like '% 123%'
Reply

Use magic Report

0

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 China

Post time: 2020-1-26 17:09:02
| Show all posts
select * from person where charindex ('123', id)> 0
Reply

Use magic Report

0

Threads

7

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-28 15:09:01
| Show all posts
Upstairs are the answers, haha
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