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:out value="${row.id}"/></td>
<td><c:out value="${row.first_name}"/></td>
<td><c:out value="${row.last_name}"/></td>
<td><c:out value="${row.user_name}"/></td>
<td><c:out value="${row.phone_number}"/></td>
<td><c:out value="${row.phone_name}"/></td>
<td align="center"><c:out value="${row.login_status}"/></td>
<td align="center"><c:out value="${row.contacts}"/></td>
</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, /* phone
number */ " +
"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; ";
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]