Cause i tried running the count through a query and it told me i could not do that..its ambigious!!! What a nice english word http://bbs.prog365.com/images/sites/smile.gif
Can someone help me please?
I have a dbgrid in delphi which i populate with a normal query.Excet that i read from 3 tables. Now the the thing is i want the amount of records in the grid? Is there a way of doing it without doing another query with a record count.Cause i tried running the count through a query and it told me i could not do that..its ambigious!!! What a nice english word
Can someone help me please?
Without the code (SQL) I don't know how we can figure out why you get the "ambiguous" error.
You should, however, try and think in terms of the dataset, not the grid.
The grid is just a display vehicle and, not withstanding appearances, only really knows about the rows it is currently displaying.
I assume you are making an error in converting the original query into a count query.
I don't think the original query could run if its result was "ambiguous".
Clive
Cause i tried running the count through a query and it told me i could not do that..its ambigious!!! What a nice english word http://bbs.prog365.com/images/sites/smile.gif
Can someone help me please?
No thanks, you are spot on there.. i never use the record count of the query component.Cause for some reason it always gives you a -1 as teh count..i must admit i did not try it before you mention it but that also does not work.!!
Thanks for teh reply though
I might just add CLIVE (who is on this forum all the time and is very good) explained that not all datasets support the record count procedure.He explained it in one of my earlier questions last year..I suppose thats why i knew it will not work!!!
i took the same query that i used to populate the grid. The is just a select * from etc...
Sorry to ask another question (but I do see a possible problem).
You are referencing three tables but you refer to
"Select * " with no alias designations.
Is that absolutely correct?
If so, are you getting all the columns from all the tables or just the columns from table a (clients)?
What happens if you use Select count(*) instead of Select count(a.accountnumber) ?
Originally Posted by clivew
Sorry to ask another question (but I do see a possible problem).
You are referencing three tables but you refer to
"Select * " with no alias designations.
Is that absolutely correct?
If so, are you getting all the columns from all the tables or just the columns from table a (clients)?
What happens if you use Select count(*) instead of Select count(a.accountnumber) ?
Well, i did not think a count on 3 tables will work. But surely there must be a way. And yes i am using select * from the 3 tables cause the tables are not that big so it loads pretty quickly in the grid. But the count is a nightmare.
Ive tried saying select count(*) and i got the following error :
"Mixing of GROUP columns (MIN(), MAX(),COUNT()....) with no GROUP columns is illegal ! there is no GROUP by clause "
I must say its pretty frustration that you can to nice selects from 2 3 or even 4 tables and do "cross selects" over multiple databases but a simple count is not possible.
Well i suppose i can probable use the query to load a gird and run a while loop and get the count but then you get that scrolling affect each time the grid loads! Not ideal at all.
Any other ideas?
I am not always as good as I could be about asking the questions.
There should be no problem with the count on a query with multiple tables if the SQL is correct. You are asking for a count of the resulting dataset. The number of tables to create it is irrelevant.
Let me try again.
Is this the exact SQL that works?
Code:
select *
from table clients a, claims b, moreinfo c
where a.accountnumber = b.accountnumber
and a.accountnumber = c.accountnumber
and a.loadeddate >=:vFromDate
and a.loadeddate <=:vToDate
Copy Code
If so, are you getting every column from clients, claims and moreinfo in the result set?
Cause i tried running the count through a query and it told me i could not do that..its ambigious!!! What a nice english word http://bbs.prog365.com/images/sites/smile.gif
Can someone help me please?
Hi Clive
Yes its precisely the code that use.
Do you want me to specify the fields instead of doing the *? Cause i tried both. The same error