Thanks Nathan, I think I will go with "SELECT * FROM table_name WHERE Name LIKE > '%$name%'";
NOBBY ----- Original Message ----- From: Nathan Bank <[EMAIL PROTECTED]> To: Tshering Norbu <[EMAIL PROTECTED]> Sent: Friday, February 08, 2002 12:25 PM Subject: Re: SELECT query with TRIM and LIKE > What is the point of the trim? Why can't you simply "SELECT * FROM table_name WHERE Name LIKE > '%$name%'"; > > Then, if the user types "Rob", they'll get Robert, Robert Downing, etc. If they type in "Robert D", > they'll get Robert Downing. If you trimmed "Robert D" into "RobertD" with the trim() function, you > would not match Robert Downing any longer. Is that different from what you want? > > By the way, if your &'s are meant to join that info together, as it appears, you need to change them > to .'s. A dot joins things. & is a bit-wise comparison... Also, $query is a variable, not a > function. Either lose the parens (), or add a function to the beginning, like so: > > $query = mysql_query("SELECT * FROM table"); > > Hope that helps, > > # Nathan > > ----- Original Message ----- > From: "Tshering Norbu" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, February 05, 2002 10:29 PM > Subject: SELECT query with TRIM and LIKE > > > > Dear list, > I have a telephone database which has "Name" as one of the fields/columns. > This field contains single name e.g Robert, double names e.g Robert > Downing and more than double names. I want to make a SELECT query using a > form whose input name is "Name" i.e '$Name' against the "Name" field in the > database. One can type a part/full of one part of the name, or part/full of > two parts of a name and goes on likewise for more than double names in the > input form. > > I believe this SELECT query is accomplished using TRIM and LIKE, something > like: > > $query = ("SELECT * from table_name where Name like '%" & Trim($Name) & "%' > "); > > This $query is not working. > Could sombody please provide me a query statement that I could use for my > above requirement. > > Thank you so much. > > NOBBY > > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php