|
how do i get this query into a variable
"select min(someField) from someTable"
|
|
|
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.
|
|
|
|
|
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)
|
|
|
|
|
'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
|
|
|
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.
|
|
|
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
|
|
|