Skip to content
Advertisement

error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax

I HAVE this query and error :

error message :

A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘JOIN provinsi as provinsi ON provinsi.IDProvinsi = lokasi_wisata.IDP’ at line 3 select id_lw,judul_lw,left(deskripsi_lw,30)deskripsi_lw,latitude_lw,longitude_lw, nama_p,nama_k,status_lw,gambar_lw from lokasi_wisata ORDER BY id_lw ASC JOIN provinsi as provinsi ON provinsi.IDProvinsi = lokasi_wisata.IDProvinsi JOIN kabupaten as kabupaten ON kabupaten.IDKabupaten = lokasi_wisata.IDKabupaten where judul_lw like ‘%%’ limit 0, 10 Filename: C:/xampp/htdocs/mtma/application/models/pagination_model.php Line Number: 21

query :

 $sql = "select id_lw,judul_lw,left(deskripsi_lw,30)deskripsi_lw,latitude_lw,longitude_lw,
                nama_p,nama_k,status_lw,gambar_lw
                from lokasi_wisata ORDER BY id_lw ASC JOIN
                provinsi as provinsi ON provinsi.IDProvinsi = lokasi_wisata.IDProvinsi JOIN
                kabupaten as kabupaten ON kabupaten.IDKabupaten = lokasi_wisata.IDKabupaten where judul_lw like '%$st%' limit " . $start . ", " . $limit  ;

Advertisement

Answer

the order by part is not located correctly. it belongs in the end, not before the join:

$sql = "select id_lw,judul_lw,left(deskripsi_lw,30)deskripsi_lw,latitude_lw,longitude_lw,
                nama_p,nama_k,status_lw,gambar_lw
                from lokasi_wisata JOIN
                provinsi as provinsi ON provinsi.IDProvinsi = lokasi_wisata.IDProvinsi JOIN
                kabupaten as kabupaten ON kabupaten.IDKabupaten = lokasi_wisata.IDKabupaten where judul_lw like '%$st%' ORDER BY id_lw ASC limit " . $start . ", " . $limit  ;
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement