Re: Another newbie question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Montag, 6. September 2004 23:50 schrieb Pete Holsberg:
[...]
> $sql = "SELECT * FROM $table ";
> $sql .= "WHERE `LastName` LIKE $search_string ";
> $sql .= "OR `FirstName` LIKE $search_string ";
> $sql .= "OR `Spouse` LIKE $search_string ";
> $sql .= "OR `Street` LIKE $search_string ";
> $sql .= "OR `Email` LIKE $search_string LIMIT 0, 30 ";
> $sql .= "ORDER BY Street, HouseNum, LastName";
How about  
$search_string .= $search_string . "%";
$sql = "SELECT * FROM $table ";
 $sql .= " WHERE LastName LIKE '$search_string' ";
$sql .= " OR FirstName LIKE '$search_string' ";
$sql .= " OR Spouse LIKE '$search_string' ";
$sql .= " OR Street LIKE '$search_string' ";
$sql .= " OR Email LIKE '$search_string' LIMIT 0, 30 ";
$sql .= " ORDER BY Street, HouseNum, LastName";
>   $result = mysql_query($sql)
>        or die ("Couldn't execute query.");
>  ...
>
> -------------
>
> Why is that?
>
> Also, how do I make LIKE insensitive to case?
As far as I know LIKE is case insensitve.
> And finally, how do I use the % wildcard with a variable?
See above.

You're welcome

-- 
Wolfgang Ebneter
MSc. Data Engineering
Fingerprint : 9C66 28A8 7AD8 BA59 6CBB  055C D664 D8FA 8CBA 800C
Key-Server : wwwkeys.eu.pgp.net

Attachment: pgpAmyzDWgbXr.pgp
Description: signature


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux