Re: Mysql querie problems
Bill Karwin wrote:
> avandenbroeck wrote:
>> The following code does not select the appropiate fields, it select
>> everything with in a zip code ( as an example)and so on. I have tried to
>> modify but I am a rookie and everything I tried has failed. please
> .. . .
>> where (keyword like '$keyword%' and zip='$zip'
>> or key2 like '$key2%' and zip='$zip'
>> or key3 like '$key3%' and zip='$zip'
>> or name like '$name%' and zip='$zip'
> I would guess that one of the following variables are a blank string:
> $keyword, $key2, $key3, $name
> For instance, if $key2 is blank, then you'll have a term in your query:
> key2 LIKE '%' AND zip='01234'
> A LIKE predicate comparing with '%' is always true.
> So print the resulting string $query after you've interpolated all your
> variables into it, and look for occurrances of '%'.
> Regards,
> Bill K.
I agree with Bill - also is it not logically the same to write the query
as;
where
(keyword like '$keyword%'
or key2 like '$key2%'
or key3 like '$key3%'
or name like '$name%')
and zip='$zip'
|