From: Peter Brawley Date: March 8 2006 3:08pm Subject: Re: query problem List-Archive: http://lists.mysql.com/mysql/195542 Message-Id: <440EF383.8020504@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit ross@stripped wrote: > I am fairly new to sql and am now getting into the area of slightly > more complex queries. > > At present my query is > > $query = "SELECT * FROM $table_name WHERE sname LIKE '$search_string%' > ORDER BY fname $type"; > > but I have two other filters which may or may not be chosen. (area, > and interest). > > $query = "SELECT * FROM $table_name WHERE sname LIKE '$search_string%' > AND area='area' AND interest='interest' ORDER BY fname $type"; > > but what if nether is chosen, or only one? Is there an AND/OR operator > or similar in mysql? No AND/OR. It's the job of the front-end, ie your app, to assemble to correct number of Where clauses. PB > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.375 / Virus Database: 268.2.0/275 - Release Date: 3/6/2006