简体   繁体   中英

how does ' ' i.e single quote space single quote work in sql?

I observed that this query returns all values from the database.

SELECT * FROM projround3.add_user where user_email like '%' '%';

Why is that?

This query:

SELECT *
FROM projround3.add_user
WHERE user_email like '%' '%';

Would not be valid in most databases. Some interfaces concatenate adjacent strings, so this is interpreted as:

SELECT *
FROM projround3.add_user
WHERE user_email like '%%';

The two wildcards are the same as one. This will match every non-NULL value.

If you want to find emails with a space, then correct logic is:

SELECT *
FROM projround3.add_user
WHERE user_email like '% %';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM