List:General Discussion« Previous MessageNext Message »
From:Jim Faucette Date:July 17 1999 4:31pm
Subject:Re: MySQL SELECT Query Question
View as plain text  
Robert W. Castley @ Home wrote:
> 
> HI,
> 
> I hope some one out there can help me with a little problem :-
> 
> Scenario :-
> 
> Example ....
> 
> I have a database in MySQL with the following example fields and example
> data in database test, tablename friends:-
> 
> NAME               STARSIGN        CAR        NICKNAME
> robert                aquarius             volvo        bob
> richard                                          audi         dick
> edward             aries                                    ted
> christopher                                   volvo
> 
> Now when you issue SELECT * from friends I would retrieve 4 records.
> 
> robert,aquarius,volvo,bob
> richard,NULL,audi,dick
> edward,aries,NULL,ted
> christopher,NULL,volvo,NULL
> 
> If I issue SELECT * from friends where car = 'volvo' I would retrieve 2
> records.
> 
> robert,aquarius,volvo,bob
> 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)

  jim...
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