Chris Walker Chris Walker - 1 year ago 75
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'.

Answer Source

"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 -------^---^
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download