Is there something I can put in my WHERE clause to only select fields from a column where that field does not contain a certain string. In this case, I am looking through to make sure the codes in this particular field do not have a "cs" in it. The code could be something like cs023 or bg425, just to give you a little bit more of an idea what I'm looking to do.
In MySQL, when you try to select a column that isn't used in the GROUP BY clause, or in an aggregate function inside the statement, it is not a valid statement according to SQL standard and will cause an error.
Use the SUBSTRING() function. The first argument is the string or the column name. The second argument is the index of the character at which the substring should begin. The third argument is the length of the substring.
The SUBSTRING SQL function is very useful when you want to make sure that the string values returned from a query will be restricted to a certain length. In the following example, using the 'firstname' column, the last two characters are matched with the word 'on' using the SQL SUBSTRING function in the where clause.
You can use
WHERE [column] NOT LIKE '%cs%'
Replace [column] with your column name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With