Forum Moderators: coopster

Message Too Old, No Replies

Another quick MySQL Quiz!

A few q's about LIKE and NOT LIKE

         

ahmedtheking

10:51 am on Dec 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am trying to pull some stuff out of my database with PHP and MySQL, but I can't seem to figure out how to put this together:

SELECT * FROM WebSite where pgname NOT LIKE 'pr%' and 'cn%' and 'cl%' and 'sv%'

If you don't get the gist of it, I want all the rows in the database as long as they dont begin with pr, cl, cn or sv.

I had a look @ the MySQL site and just got lost!

Salsa

11:00 am on Dec 31, 2004 (gmt 0)

10+ Year Member



I think you just need to use a NOT LIKE before each condition, e.g.:

SELECT * FROM WebSite WHERE pgname NOT LIKE 'pr%' AND pgname NOT LIKE 'cn%' AND pgname NOT LIKE 'cl%' AND pgname NOT LIKE 'sv%'

...there may be a shortcut to this, but I don't know it.

I hope this helps.

ahmedtheking

2:02 pm on Dec 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yea that worked! thank you!

ergophobe

9:14 pm on Dec 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hey! Don't you owe Salsa a gold star?

jatar_k

12:33 am on Jan 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think Salsa's little book of gold stars is full, I'll have to go out and get another. ;)

ahmedtheking

2:30 pm on Jan 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Gold stars!? I hope one day I'll be competent enough to get one! :D

ergophobe

4:46 pm on Jan 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It was a quiz and he aced it. I thought he was supposed to get a gold star (BTW, for those not of certain nationalities and certain ages, this might not make sense).

Salsa

10:20 am on Jan 2, 2005 (gmt 0)

10+ Year Member



Aw, shucks. 'Twernt nothin'. No stars are necessary. Simply the gold will be fine.
;)

Ergophobe: Yes, I remember the gold stars. We'd get them for acing quizzes and also for just being "a good doobee." Now I'm really dated.