vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Does anyone know why a mysql alias would not display in the return a result? When I try to access say the first name with it's alias f_name, it is blank? , but it works for its column name first_name? This becomes more of a problem with subselects because how does one alias it? Thank you, Adam JSP: <c:set var="resultObj" value="${sessionScope[\"javax.servlet.jsp.jstl.sql.Result\"]}" /> <table border="1" cellspacing="2"> <tr> <th>User ID</th> <th>First Name</th> <th>Last Name</th> <th>User Name</th> <th>Phone Number</th> <th>phone_name</th> <th>login Status</th> <th>Number of Contacts</th> </tr> <c:forEach items="${resultObj.rows}" var="row"> <tr> <td align="center"><c <td><c <td><c <td><c <td><c <td><c <td align="center"><c <td align="center"><c </tr> </c:forEach> </table> Servlet sql: sql = "SELECT " + "u.id as user_id, " + "u.first_name as fname, " + "u.last_name, " + "u.user_name, " + "SUBSTRING(d.contact_url, 5,10) as phone_number, /* phonenumber */ " + "pt.phone_name, " + "a.login_status, " + "COUNT(c.user_id) as contacts " + "FROM " + "device as d, "+ "client_relations as cr, " + "phone_types as pt, " + "availability as a," + "usr as u " + "LEFT JOIN " + "contact AS c " + "ON " + "( u.id = c.user_id) " + "WHERE " + "u.id = d.user_id " + "AND " + "d.client_relation_id = cr.id " + "AND " + "cr.phone_type_id = pt.id " + "AND " + "u.id = a.user_id " + "AND " + "a.device_id = d.id " + "AND " + "a.login_status > 3 " + "GROUP BY " + "u.id " + "ORDER BY " + "a.id LIMIT 2; "; |
| ||||
| On Wed, 2006-10-11 at 16:03 -0700, ADAM CZECH wrote: > Does anyone know why a mysql alias would not display in the return a > result? > > When I try to access say the first name with it's alias f_name, it is > blank? , but it works for its column name first_name? This becomes > more of a problem with subselects because how does one alias it? > Servlet sql: > > sql = "SELECT " + > "u.id as user_id, " + > "u.first_name as fname, " + You're aliasing it as fname, not f_name. -- Pat Adams Digital Darkness Promotions Dallas Music Wiki http://digitaldarkness.com |