=An alternative approach:- > > I am building a user search engine. Now I do not know how to gett > > following: > > > > a mandatory field and a voluntary field > > > > For example I would like to get all female users and those who are from > > canada. > > The results should show all users who are female regardless of nationality > > But it should also show all users from canada. > > > > How would this look like? > > > > SELECT * > > FROM table > > WHERE sex=1 AND country='CA' > > > > This is wrong I know. But how does it work??? > > SELECT * FROM TABLE > WHERE sex = 1 OR country = 'CA'; > > Will select all users who are female as well as all users from Canada. You > may get duplicate records (for people who are female and from Canada) so you > may want to use DISTINCT as well.
=If all you want to do is to 'highlight' people from Canada, whilst having a query that gives a worldwide resultset, try: SELECT *, IF( country = 'CA', 'Canuck', 'Normal' ) AS highlight FROM table WHERE sex=1; =Regards, =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]