visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: store query result in a variable


By: jkalahasty U.S.A.  Date: 16/07/2003 00:00:00  English  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 English  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 English  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 English  Type : Comment
no, or else I would have :D

Do register to be able to answer

EContact
browser fav
page generated in 741.101980 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page