From: Stefan Kuhn Date: February 5 2013 3:25pm Subject: Aw: SELECT subquery problem List-Archive: http://lists.mysql.com/mysql/228930 Message-Id: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable You cannot do this. A sql result alwas has the same number of columns in ea= ch row. You could have null or "" in the column, though. This could be done= via the if(,,)-statement of mysql or by using a union and two selects, one= for pub_email=3Dn and the other for the rest. Gesendet:=C2=A0Dienstag, 0= 5. Februar 2013 um 15:49 Uhr Von:=C2=A0cl An:=C2=A0mysql= @lists.mysql.com Betreff:=C2=A0SELECT subquery problem De-lurking here. 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: SELECT last_name,= first_name, phone, email FROM `mydatabasetable` WHERE `current_member` =3D= "Y" AND `pub_name` =3D "Y" ORDER BY last_name ASC This works fine, as exp= ected. But, I want to only display the value in `email` if the value in an= other field, `pub_email` =3D "Y" So, the resultant output would look like t= his, for instance, if the value of `pub_email` =3D"N" for Mr. Wills: Jones= John 555-555-5555 johnjones@stripped Smith Jim 555-222-2222 jimSmith@no= thing.com Wills Chill 555-111-1111 Zorro Felicity 555-999-9999 felicityzorr= o@stripped Can't quite figure out how to express this. TIA for your sug= gestions! -- MySQL General Mailing List For list archives: http://lists.m= ysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql[http://lists.my= sql.com/mysql]