From: Reindl Harald Date: January 2 2012 3:38pm Subject: Re: Beginner question List-Archive: http://lists.mysql.com/mysql/226547 Message-Id: <4F01CF63.8000004@thelounge.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig96D3F0A98A6F2DA9B0F2591F" --------------enig96D3F0A98A6F2DA9B0F2591F Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Am 02.01.2012 16:33, schrieb Biz-comm: > Thanks for any assistance. >=20 > Web page that needs a sort of all records with a specific state, set t= o "show", and if it exists in one of 4 categories. >=20 >=20 > Using this: >=20 > SELECT *=20 > FROM listings > WHERE listing_state =3D 'DC'=20 > AND listings.listing_show =3D'y' =20 > AND listings.cat1 =3D 23 OR listings.cat2 =3D 23 OR listings.cat3 =3D= 23=20 >=20 >=20 > Gives up 2 records in the state of DC, set to show, and are listed in c= at1. > However, it also gives up 2 records in the state of VA, set to show, bu= t are listed in cat2 (not in 1). > Any assistance most appreciated. basic math how should mysql know that the OR-clauses are meant not standalone? SELECT * FROM listings WHERE listing_state =3D 'DC' AND listings.listing_show =3D'y' AND (listings.cat1 =3D 23 OR listings.cat2 =3D 23 OR listings.cat3 =3D 2= 3) --------------enig96D3F0A98A6F2DA9B0F2591F Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk8Bz2MACgkQhmBjz394AnlA9wCdHCH4mORv2n93m4gaCXA6IV85 idAAn1M8Tj71v0UBpMhuqb83uLJtH8ub =8JfB -----END PGP SIGNATURE----- --------------enig96D3F0A98A6F2DA9B0F2591F--