Databases :: MySql :: store query result in a variable |
|||
| By: jkalahasty |
Date: 16/07/2003 00:00:00 |
Points: 25 | Status: Answered Quality : Excellent |
|
Hi I use the following query to get a value that i use in another query in the same page. but i would like to store it in a variable so that I can print it out. please let me know if its possible and how to do it. String query = "select @s:=count(*) from list where course"+ "=" + request.getParameter("T2"); String queryText = "insert into list values('" +request.getParameter("T3")+"','" +request.getParameter("T1") +"','" +request.getParameter("T2") +"',@s+1)"; the value of @s if of concern and i would like to print it in this manner say Gist of it is: I want the value returned by the query : "select count(*) from list where course"+ "=" + request.getParameter("T2");" to be stored in a string and be able to print it, not the value of request.getParameter("T2") hope I am clear |
|||
| By: VGR | Date: 17/07/2003 04:16:00 | Type : Answer |
|
| yes, but it's your programming language that is not :D look in its help or online (google etc) to see how people retrive data. In PHP that's a matter of writing $result=mysql_query("select count(*) as somealias from list where course='$T2';"); $res=mysql_fetch_array($result); $thestring=$res['somealias']; |
|||
| By: jkalahasty | Date: 17/07/2003 04:30:00 | Type : Comment |
|
| Hi vgr, thanks for responding, but my prog lang is JSP. COULD U GIVE ME THE WQUERY IN JSP? TAHNKS. |
|||
| By: VGR | Date: 17/07/2003 04:54:00 | Type : Comment |
|
| no, or else I would have :D |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








