Query syntax

Query syntax

am 15.09.2007 21:04:59 von Ron Piggott

$query="SELECT * FROM table WHERE listing_type LIKE '%$listing_type%' AND
listing_approved = '1' OR listing_approved = '2' ORDER BY name ASC";

My question is how can I search for records where listing_approved has a
value of either 1 or 2 (while in the same search I am searching for
listing_type --- ie other variables)

Ron

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Query syntax

am 15.09.2007 21:49:13 von Niel Archer

If I understood you correctly (and I'm not sure I did), this should do
it

$query="SELECT * FROM table WHERE listing_type LIKE '%$listing_type%'
AND listing_approved IN( '1' ,'2') ORDER BY name ASC";

--
Niel Archer

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Query syntax

am 15.09.2007 21:57:07 von Trevor Gryffyn

SELECT * FROM table
WHERE listing_type LIKE '%$listing_type%'
AND (listing_approved = '1' OR listing_approved = '2')
ORDER BY name ASC

(notice the parentheses around the OR part of the clause)

or you can do this...

SELECT * FROM table
WHERE listing_type LIKE '%$listing_type%'
AND listing_approved IN ('1', '2')
ORDER BY name ASC

Good luck!

-TG

----- Original Message -----
From: "ron.php"
To: php-db@lists.php.net
Date: Sat, 15 Sep 2007 15:04:59 -0400
Subject: [PHP-DB] Query syntax

> $query="SELECT * FROM table WHERE listing_type LIKE '%$listing_type%' AND
> listing_approved = '1' OR listing_approved = '2' ORDER BY name ASC";
>
> My question is how can I search for records where listing_approved has a
> value of either 1 or 2 (while in the same search I am searching for
> listing_type --- ie other variables)
>
> Ron
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php