Chris Walker Chris Walker - 3 months ago 4x
MySQL Question

display a list of publishers that contain "and" in the name mysql

I need to display a group of names from a list of publishers that contain the word "and" in them, but not display words that contain the letters "and" in them (like the word Random). How would I go about this? I'm new to all of this and haven't been able to find an answer to this question yet if there is one.

here's an example of the table:

publisher_code|publisher_name |city
FS |Farrar Straus and Giroux|New York
VB |Vintage books |New York

Basically I just want to see the publisher names that contain the word 'and'.


"And" is actually a relatively easy word to handle, as it can only appear in the middle of a sentence (name). Just slap a couple of whitespaces around it, and you should be OK:

FROM   publishers
WHERE  UPPER(name) LIKE '% AND %';
-- Note the spaces -------^---^