Divi WordPress Theme

How to perform string does not equal in MySQL

Topic: How to perform string does not equal in MySQL  (Read 1041 times)

Offline Chris

  • Junior Guru
  • **
  • Posts: 81
  • iTrader: +0/-0
    • View Profile
How to perform string does not equal in MySQL
« on: October 31, 2019, 11:24:00 AM »
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!
VPS Hosting - AccuWebHosting

Offline Kailash

  • Web Hosting Master
  • *****
  • Administrator
  • Posts: 655
  • iTrader: +153/-0
    • View Profile
Re: How to perform string does not equal in MySQL
« Reply #1 on: October 31, 2019, 11:25:47 AM »
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
Shopify Divi WordPress Theme
Tags:

Check MySQL service uptime through command line

Started by KailashBoard How Tos

Replies: 2
Views: 21213
Last post November 22, 2011, 10:03:24 PM
by Mrtu92
commands to start/stop/restart MySQL server

Started by AnonymousBoard MySQL

Replies: 2
Views: 5650
Last post October 11, 2018, 12:51:09 PM
by sankalppatil
MySQL error - Too many MySQL connections

Started by digitalpointBoard cPanel/WHM

Replies: 2
Views: 5022
Last post November 25, 2009, 07:02:28 PM
by kvchosting
check PHP and MySQL version through shell (SSH) on Linux Server

Started by KailashBoard cPanel/WHM

Replies: 10
Views: 74437
Last post January 11, 2019, 07:18:59 PM
by rubyatiy
Converting Microsoft Access Databases to MySQL

Started by TechBoard MS Access

Replies: 0
Views: 4703
Last post August 29, 2007, 02:21:15 AM
by Tech