vb.net - How to find the nearest value in the database -
how nearest value in database, example data in database value of:
data tested -100, how system can issue results of test -100 character a.

private sub button4_click(sender object, e eventargs) handles button4.click try dim persen string dim nilai_banding, hasil string dim cek = textbox1.text dim reng_atas = cek + 15 dim reng_bawah = cek - 15 dim per = " %" dim kuadrat = "^2" dim pixeluji = textbox2.text dim pixelsampel = textbox1.text 'dim c = textbox3.text 'if c > 315 'messagebox.show("jumlah pixel terlalu besar untuk di verifikasi", "informasi", messageboxbuttons.ok, messageboxicon.information) 'else 'conn.open() dim mda new mysql.data.mysqlclient.mysqldataadapter("select citra_karakter karakter_plat pixel_putih='" & textbox1.text & "' or pixel_putih >='" & reng_atas & "' , pixel_putih >='" & reng_bawah & "'", conn) '("select nama,tanda_tangan,nilai_hitam,jumlah_pixel,keterangan tanda_tangan nama '%" & textbox7.text & "%'", conn) dim dt new datatable mda.fill(dt) 'datagridview1.datasource = datagridviewautosizecolumnmode.allcells 'datagridview1.datasource = dt cmd = new mysql.data.mysqlclient.mysqlcommand("select nama_huruf,pixel_putih,pixel_hitam,jumlah_pixel,biner_karakter, citra_karakter karakter_plat pixel_putih='" & textbox1.text & "' or pixel_putih<='" & reng_atas & "' , pixel_putih>='" & reng_bawah & "'", conn) rd = cmd.executereader() rd.read() if rd.hasrows label1.text = rd.item(0) textbox2.text = rd.item(1) 'dim foto byte() = rd.item(5) end if syntax above produces output -100 = n
i want -100 = a.
my answer based find nearest values of field specific field using query:
select * ( select *, row_number() on (order abs(@specificvalue - valuefield)) seq atable) t (seq <= 1); --if want have n nearest values change `1` `n` using type of query (for example) give -99 instead of -102 @specificvalue = -100.
as alternative query (in mysql):
select * atable order abs(-100 - pixel_putih) limit 1;
Comments
Post a Comment