List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:August 4 1999 9:31am
Subject:Re: MySQL SELECT Query Question
View as plain text  
On Sa, 1999-07-17 12:31:53 -0400, Jim Faucette wrote:
> > robert,aquarius,volvo,bob
> > richard,NULL,audi,dick
> > edward,aries,NULL,ted
> > christopher,NULL,volvo,NULL
[...]
> > However if I issue SELECT * from friends where car like '%vol%'
> > and starsign like '%' I would retrieve only one record
> > 
> > robert,aquarius,volvo,bob
> 
> SELECT * FROM friends WHERE car LIKE '%vol%' AND
> (starsign LIKE '%' OR starsign IS NULL)

Another method to deal with such NULL values that sometimes comes
handy and avoids an additional OR term is to use the ISNULL()
function:

  SELECT *
  FROM friends
  WHERE car LIKE '%vol%'
    AND ISNULL(starsign,'') LIKE '%';

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
MySQL SELECT Query QuestionRobert W. Castley @ Home17 Jul
  • Re: MySQL SELECT Query QuestionWayne Topa17 Jul
    • Re: MySQL SELECT Query QuestionWayne Topa17 Jul
  • Re: MySQL SELECT Query QuestionPaul DuBois17 Jul
    • Re: MySQL SELECT Query QuestionCharles Kirby17 Jul
      • Re: MySQL SELECT Query QuestionPaul DuBois17 Jul
      • Re: MySQL SELECT Query QuestionFred Read18 Jul
  • Re: MySQL SELECT Query QuestionPat Sherrill17 Jul
  • Re: MySQL SELECT Query QuestionJim Faucette17 Jul
    • Re: MySQL SELECT Query QuestionMartin Ramsch4 Aug