[ic] Displaying number of rows in a table
Mike Heins
interchange-users@icdevgroup.org
Tue Jul 1 10:13:00 2003
Quoting Interchange User (interchange@framework.cx):
> Hello,
>
> I would like to access the number of items in a SQL table. I haven't
> had much luck getting at the results using SQL, and I'm wondering if
> there's a simple way to access mv_return_fields after pointing a
> [search] tag at one of the tables, or if it's easier to use the [query]
> tag.
>
> I know I'm doing something wrong , but this is what I've been trying:
> ------------------------------------------------------------------------
> -----
> [query
> sql="select count(*) as requestcount from www_mediarequest"
> type=list
> list=1
> st=db
> ]
> [list]
> [sql-param requestcount]
> [/list]
> [/query]
> ------------------------------------------------------------------------
> -----
> IC 4.9.8 nightly
> MySQL 4.1 alpha
>
That should work, but some things depend on your database setup.
If your products database was GDBM, for example, that would not
work and you would have to add a base=www_mediarequest parameter
to give IC the correct database handle to start from.
In any case, this should work:
[query
list=1
base=www_mediarequest
sql="select count(*) from www_mediarequest"
][sql-code][/query]
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.513.523.7621 <mike@perusion.com>
Research is what I'm doing when I don't know what I'm doing.
-- Wernher Von Braun