help with getting my room count to show correctly!

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Thunder
Posts: 3
Joined: Mon 19 Jan 2009 11:31

help with getting my room count to show correctly!

Post by Thunder » Fri 23 Jan 2009 21:02

ok i finaly worked out how to get each selected room but now i have a problem when i try to add the room count to the client it sends the room count as one big number like 1123 and not for each lobby

IE

LOBBY 1 - 3 ROOMS
LOBBY 2 - 1 ROOMS
LOBBY 3 - 50 ROOMS

the way it looks right now is as follows

LOBBY 1 - 3150
LOBBY 2 - 3150
LOBBY 3 - 3150

can anyone help me please thanks P.S my sql is not best so demos would be helpful ...

Code: Select all

 MyQuery.SQL.Text := 'SELECT count(*),groups.name,groups.n FROM groups,rooms WHERE groups.n=rooms.id GROUP BY name';
 MyQuery.Execute;

 while not MyQuery.Eof do begin
   MyQuery.Next;
 end;

   s := s  + 'šRGetGroupsœ'
           + GroupsTable.FieldByName('Name').AsString +'œ' //
           + IntToStr(n) +'œ'
           + GroupsTable.FieldByName('LobbyRate').AsString +'œ'
           + h +'œ'
           + MyQuery.Fields[0].AsString +'œ' // room count
           + k +'œ';
thanks

Tiko12
Posts: 5
Joined: Fri 23 Jan 2009 22:30
Location: Denmark

Need more info...

Post by Tiko12 » Sun 25 Jan 2009 14:42

Hello Thunder

Without knowing your db schema - it is hard to tell exactly what is wrong...

By looking at the snippet You reveal - it seam like You show the rate - is the rate 3150 ?

regards Tiko

Thunder
Posts: 3
Joined: Mon 19 Jan 2009 11:31

Post by Thunder » Sun 25 Jan 2009 18:58

no it shows the correct room count but just in one big line it dont split the count for each lobby

Tiko12
Posts: 5
Joined: Fri 23 Jan 2009 22:30
Location: Denmark

GROUP BY

Post by Tiko12 » Sun 25 Jan 2009 19:32

- it sounds like You should use GROUP BY - lobbyXX then

Dont know if thats what You are looking for...

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Mon 26 Jan 2009 08:50

Code: Select all

var query : string;
      S : string;
begin
  with myquery do
  begin
     query := 'SELECT count(*) AS totalrooms, groups.id groups.name, groups.n FROM rooms  GROUP BY groups.id JOIN groups on groups.id = rooms.id'; 
     SQL.text := query;
     Active := true;
     while not eof do
     begin
       S := format('%s'#8'%2d rooms',[fieldbyname('name').AsString, 
                          fieldbyname('totalrooms').AsInteger]);
       showmessage(S);
     end;
  end;
end;
Someting like this

Post Reply