Click here to Skip to main content
15,902,032 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
in sql i use select the query using some condition value have new line space or double space

in that i did not got any result

What I have tried:

**Example:
SQL
select name from username where name like '% senr lim mintu%'


if i give like this:
SQL
select name from username where name like '% senr %'

i got result

customer have gave like new line or double space as before i try**
Posted
Updated 10-May-24 7:42am
v2
Comments
Richard Deeming 10-May-24 3:28am    
Your question is not clear.

If your first query doesn't return any results, that means there are no records in your table which match the condition you're searching for.

We cannot access your database, so we have no idea what the data actually looks like, and we can't tell you how to fix your query.
CHill60 10-May-24 3:58am    
You should validate user input before storing it on your database to prevent stuff like this from happening.

1 solution

The SQL LIKE condition is pretty basic: it doesn't support regular expressions without managed code (which is it's own can of worms).
All you get are character ('[' followed by a character list then ']'), not a character ('[^' followed by a character list then ']'), match any character ('_') and match any number of characters ('%')

You want to match optional double spaces and so forth, you need to either invest time in learning SQL managed code[^], change how you store data, or do the work in your presentation language instead of SQL.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900