codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  very simple question  Gasolene at 22:01 on Tuesday, September 16, 2003
 

how do i get this query into a variable

"select min(someField) from someTable"

  Re: very simple question  David Bruce at 22:02 on Friday, September 19, 2003
 

I assume you mean because you can't access it in the normal way of objrs("variable_name") - that puzzled me for a while too!

One way I learned is to use objrs(0) - where the number 0 refers to the first field in the query. You can access further fields if you have them, using objrs(1), objrs(2) and so on.

If this isn't what you meant, please give us some more info.
David Bruce: site expert
CodeToad.com


  Re: very simple question  Troy Wolf at 15:21 on Saturday, September 20, 2003
 

You can also name your columns like so:

sql = "select min(someField) as ""MinDate"" from someTable"

Then you can use this name as the column name:

MinDate = objRS("MinDate")

I use this method when including a function column in a long list of other columns. However, when returning a single value or maybe 2 or three, I usually just use the index method as David showed.

MinDate = objRS(0)
Troy Wolf: site expert
SnippetEdit Website Editor


  Re: very simple question  nicholasbritton at 22:54 on Saturday, September 20, 2003
 

'Min' is one of the SQL 'aggregate' functions. As such it returns a single value. your query will return a single record with one field. if you are using an ADO recordset object, the value will be contained in 'rs(0)'.

Hope this helps

Nick

  Re: very simple question  Rutuja at 12:13 on Monday, October 13, 2003
 

u can create dynamic recordset.
in that recordset..crte as much columns as u want .provide anmes to those cols and while storing data..store it in those cols as it is a table.

  Re: very simple question  Elain at 08:16 on Friday, November 19, 2010
 

1. {dede:field.cnartist runphp=yes}
2. $tsql = new DedeSql(false);
3. $titlelist = '';
4. $tsql->SetQuery("Select mu.*,a.id From #@__music mu,#@__archives a where mu.cnartist =''@me'' and mu.aid = a.id");
5. $tsql->Execute('t');
6. while($row = $tsql->GetArray('t',MYSQL_ASSOC)){
7. $titlelist .= "<li>".$row['entitle']."</li> "; }
8. @me=$titlelist;
9. {/dede:field.cnartist}
----------------------------------------------------------------------------------
flash banner|logo maker|flash menu|drop down menu|flash decompiler mac








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: finding Field size
•  Re: Diplay uploaded files
•  Re: DHTML Menu
•  Re: A new Begining
•  Re: Playing Sound Waves
•  Re: welcome
•  Re: Create desktop icon
•  Re: how to write games on PDA
•  Stephen Arnold on real-time search


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2010