Android Question Another mysql statement help

tufanv

Expert
Licensed User
Longtime User
Hello,

I need another help for a mysql statement to use in my php file to send a json to my app.
I have 2 tables on mysql. One of them is tblliste other one is tblverilen

currently i am using :
B4X:
SELECT * FROM tblliste left join tblverilen on tblliste.id=tblverilen.id where tblliste.username = '".$usn."'

to get the entries from tblliste and list them in my app.

What i need to add is ( and i can't manage to add ) for each found entry in tblliste with above code , I want to get the number of rows which "id" column in tblverilen is equal to each tblliste.id found .

for example lets say we have 5 different ids in tblliste for the username=$usn : 1,2,3,4,5
I want to get the number of rows in tblverilen for each of the above ids ( how many row'd id column is 1 , how many row's id column is 2 , how many row's id column is 3 ... )

is it possible ?

ty
 

rudystyle

Member
Licensed User
Longtime User
use group by

B4X:
SELECT count(*),tblliste.username FROM tblliste left join tblverilen on tblliste.id=tblverilen.id where tblliste.username = '".$usn."' .  Group by tblliste.username
 
Last edited:
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
B4X:
$tryThisQuery= "select distinct(tblverilen.id),count(1),tblliste.* from tblverilen left join tblliste on tblliste.id=tblverilen.id where tblliste.username='$usn' group by tblverilen.id";
 
Upvote 0
Top