How can I read with SQL COUNT(*) the Number of entries
Hi,
I don’t know to read the number of entries in a table. (I would like to use asp:Repeader)
sql = "SELECT COUNT(*) FROM Table";
<asp:Repeater id="Repeater01" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "????????") %>
</ItemTemplate>
</asp:Repeater>
What is the ???? Statement?
Thanks.
Edit: This is my SQL-Statement:
select t.tip_adi, count(oda.oda_tip_id) from oteldb.tip t
left join (select oda_tip_id from oteldb.oda o
where not exists (
select null from oteldb.rezervasyon r
where r.rezervasyon_oda_id = o.oda_id
and r.rezervasyon_gt <= '2012-01-22'
and '2012-01-03' <= r.rezervasyon_c
) ) oda on oda.oda_tip_id = t.tip_id
group by t.tip_adi
You need to alias the COUNT(*), like this:
sql = "SELECT COUNT(*) AS MyCount FROM Table";Now you have a defined column name you can begin to use as
MyCount.So now you can do:
Based on your comment your query would become this:
select t.tip_adi, count(oda.oda_tip_id) AS MyCount from oteldb.tip t left join (select oda_tip_id from oteldb.oda o where not exists (select null from oteldb.rezervasyon r where r.rezervasyon_oda_id = o.oda_id and r.rezervasyon_gt <= '2012-01-22' and '2012-01-03' <= r.rezervasyon_ct) ) oda on oda.oda_tip_id = t.tip_id group by t.tip_adiNotice the “MyCount”. Now you can use what I posted above to bind that value.