Re: HOw to modify a php database query from general to specific?

From: Date: Thu, 22 May 2003 12:18:36 +0000
Subject: Re: HOw to modify a php database query from general to specific?
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-20034@lists.php.net to get a copy of this message
SELECT * FROM table1 WHERE field2='donuts' AND field3 LIKE '%text%' where text could be anything from none to any chars combination. This will search into chars, text, varchars field types but not on number for anything that contain the text part. If text is empty will return everything. I hope this helps ------------------------------------------------- Cristian MARIN InterAKT Online (www.interakt.ro) cristic@interakt.ro ----- Original Message ----- From: Acorn Tutors Newsgroups: php.windows To: php-windows@lists.php.net Sent: Thursday, May 22, 2003 3:07 PM Subject: HOw to modify a php database query from general to specific? Hi folks, I have a database query that I wanted to modify. If a person wanted to search for any item in a field (i.ie. NO Preference in a Web page form), but only certain items in another field, how would I set up the php code to do this Would it be something like this? select * from TABLE1 where FIELD2 = donuts AND FIELD3 = ???? What would I put in the ???? to indicate that I wanted to select everything from FIELD3. I ask this because if the user actually selects an item for the FIELD3 query (as opposed to no preference), the query must be able to allow for specific searches as well as being able to search all. In other words, are there any wildcards that can be used to easily make it so that the query can be as broad as any row in FIELD3 or as specific as single rows in FIELD3. Help appreciated, Doug

« previous php.windows (#20034) next »