• Welcome to Web Hosting Forum - A Web Hosting Community for Webmasters.
 

Recommended Providers



WordPress Hosting

Jetpack
Fully Managed WordPress Hosting
lc_banner_leadgen_3
Fully Managed WordPress Hosting

WordPress

WordPress Hosting Divi WordPress Theme
WPZOOM
Bluehost WordPress Hosting

Forum Membership

Forum Membership

How to perform string does not equal in MySQL

Started by Chris, October 31, 2019, 11:24:00 AM



Chris

I have the following mysql query:

    SELECT * FROM table WHERE name <> 'username';

I am expecting to return all the results where name is not the string username, But this not working. Am I doing wrong?

Thanks!

Kailash

Your "where" clause will return all rows where name does not match username AND where name is not null.

If you want to include NULL results as well, you can try following where clause:

    where name <> 'username' or name is null

If you are looking for strings that do not contain the word "username" as a substring, then like can be used:

    where name not like '%username%'

- Kailash


WordPress Hosting