I am sure tihs one is easy
I am running the following query in a TUniQuery to determine how many unique pars there are in the table.
select count(par) from table group by parent
How do I get at the value count(par)
Paul
getting result of count(x)
-
MamProblem
- Posts: 13
- Joined: Mon 09 May 2011 11:11
For Delphi:
For C++:
But it's easier to entitle your field like that:
...
SELECT COUNT(par) as "parent_lol_test" FROM table GROUP BY parent
...
Query->FieldByName('parent_lol_test')->AsString;
Hope I helped U a lil'bit
Code: Select all
Query : TUniQuery;
Query.Create(Self); // dunno if it's correct, I don't code in Delphi ;)
Query.SQL.Text := 'SELECT COUNT(par) FROM table GROUP BY parent;';
Query.Open;
ShowMessage(Query.FieldByName('count').AsString);
Query.Free;
Code: Select all
TUniQuery *Query = new TUniQuery(NULL);
Query->SQL->Text = "SELECT COUNT(par) FROM table GROUP BY parent;";
Query->Open();
ShowMessage(Query->FieldByName('count')->AsString);
delete Query;
...
SELECT COUNT(par) as "parent_lol_test" FROM table GROUP BY parent
...
Query->FieldByName('parent_lol_test')->AsString;
Hope I helped U a lil'bit
-
AndreyZ
You can use the following code:
Code: Select all
UniQuery.SQL.Text := 'select count(par) from table group by parent';
UniQuery.Open;
ShowMessage(UniQuery.Fields[0].AsString);