tufanv Expert Licensed User Longtime User Apr 18, 2016 #1 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 : Code: Copy 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
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 : Code: Copy 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
R rudystyle Member Licensed User Longtime User Apr 18, 2016 #2 use group by Code: Copy SELECT count(*),tblliste.username FROM tblliste left join tblverilen on tblliste.id=tblverilen.id where tblliste.username = '".$usn."' . Group by tblliste.username Last edited: Apr 18, 2016 Upvote 0
use group by Code: Copy SELECT count(*),tblliste.username FROM tblliste left join tblverilen on tblliste.id=tblverilen.id where tblliste.username = '".$usn."' . Group by tblliste.username
tufanv Expert Licensed User Longtime User Apr 18, 2016 #3 thanks but this does not do what i want, maybe i could not describe the problem well. Upvote 0
mc73 Well-Known Member Licensed User Longtime User Apr 18, 2016 #4 Code: Copy $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
Code: Copy $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";