2015-11-13 57 views

回答

0

如果你的意思2利用此行,

select * from table_name where baris = 2; 

如果你想如果你想使用ORDER BY子句只獲取第二排

select * from table_name LIMIT 1, 1; 

,您可以使用,以及(只有當您在尋找2nd largest or 2nd smallest。)

+0

上面的表是mysql查詢的結果,請問如何在獲取結果時只顯示第二行I –

+0

,只讀取一行。然後顯示那一行。 –

+0

如何在數組結果中只顯示行? $導致[2]; ? –

0

這是我的查詢

 SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai 
     ON nilai.id_data_nilai = data_nilai.idx 
      WHERE data_nilai.id_tahun_ajar = '1' 
       AND data_nilai.id_sekolah = '1040902040' 
       AND data_nilai.id_kelas = '2' 
       AND data_nilai.id_rombel = '2' 
       AND data_nilai.id_mapel = '13' 
       AND data_nilai.status_nilai = '0' 
       AND data_nilai.id_jn = '1' 
       AND nilai.user_id = 'IDS0000707' 
    UNION 
    SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai 
     ON nilai.id_data_nilai = data_nilai.idx 
      WHERE data_nilai.id_tahun_ajar = '1' 
       AND data_nilai.id_sekolah = '1040902040' 
       AND data_nilai.id_kelas = '2' 
       AND data_nilai.id_rombel = '2' 
       AND data_nilai.id_mapel = '13' 
       AND data_nilai.status_nilai = '0' 
       AND data_nilai.id_jn = '2' 
       AND nilai.user_id = 'IDS0000707' 

    UNION 
     SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai 
     ON nilai.id_data_nilai = data_nilai.idx 
      WHERE data_nilai.id_tahun_ajar = '1' 
       AND data_nilai.id_sekolah = '1040902040' 
       AND data_nilai.id_kelas = '2' 
       AND data_nilai.id_rombel = '2' 
       AND data_nilai.id_mapel = '13' 
       AND data_nilai.status_nilai = '0' 
       AND data_nilai.id_jn = '3' 
       AND nilai.user_id = 'IDS0000707' 
    UNION 
     SELECT SUM(nilai.nilai) as total, COUNT(nilai.nilai) as baris FROM nilai JOIN data_nilai 
     ON nilai.id_data_nilai = data_nilai.idx 
      WHERE data_nilai.id_tahun_ajar = '1' 
       AND data_nilai.id_sekolah = '1040902040' 
       AND data_nilai.id_kelas = '2' 
       AND data_nilai.id_rombel = '2' 
       AND data_nilai.id_mapel = '13' 
       AND data_nilai.status_nilai = '0' 
       AND data_nilai.id_jn = '8' 
       AND nilai.user_id = 'IDS0000707' 
+0

@niranjan ..這是我的查詢 –

相關問題