From: Carlos Eduardo Caldi Date: February 5 2013 3:14pm Subject: RE: SELECT subquery problem List-Archive: http://lists.mysql.com/mysql/228929 Message-Id: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="_f9a02f60-056c-4a15-8c89-513466531e2b_" --_f9a02f60-056c-4a15-8c89-513466531e2b_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Afternoon You can do: SELECT last_name=2C first_name=2C phone=2C if(pub_email=3D"Y"=2Cemail=2C"")= as email FROM `mydatabasetable` WHERE `current_member` =3D "Y" AND `pub_na= me` =3D "Y" ORDER BY last_name ASCI thin de function if=2C can solve your p= roblem=2C Att=2C Carlos Caldi > From: cl@stripped > To: mysql@stripped > Subject: SELECT subquery problem > Date: Tue=2C 5 Feb 2013 09:49:47 -0500 >=20 > De-lurking here. >=20 > I am trying to figure out how to return results from a query. What I need= to do is to return 4 columns from a database. This is easy: >=20 > SELECT last_name=2C first_name=2C phone=2C email FROM `mydatabasetable` W= HERE `current_member` =3D "Y" AND `pub_name` =3D "Y" ORDER BY last_name ASC >=20 > This works fine=2C as expected. >=20 > But=2C I want to only display the value in `email` if the value in anothe= r field=2C `pub_email` =3D "Y" So=2C the resultant output would look like = this=2C for instance=2C if the value of `pub_email` =3D"N" for Mr. Wills: >=20 > Jones John 555-555-5555 johnjones@stripped > Smith Jim 555-222-2222 jimSmith@stripped > Wills Chill 555-111-1111 > Zorro Felicity 555-999-9999 felicityzorro@stripped >=20 > Can't quite figure out how to express this. >=20 > TIA for your suggestions! >=20 >=20 > --=20 > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: http://lists.mysql.com/mysql >=20 = --_f9a02f60-056c-4a15-8c89-513466531e2b_--