I have a column kd_barang2 as an id in my table. The values is like this: 010000101.
I want to select the first 7 number (0100001) and then show it.
The script to select is like this:
$queryalat1="select * from tb_master
where kd_barang2 = '".$data1['kd_barang2']."'
&& jenis_barang='alat habis pakai'
Group by merk_barang";
and then I tried this kind of code
$queryalat1="select * from tb_master
where SUBSTRING(kd_barang2,0,7) = '".substr($data1['kd_barang2'],0,7)."'
&& jenis_barang='alat habis pakai'
Group by merk_barang";
but it failed, because it didn't show any data in my table.