query pencarian php

Discussion in 'Desain Web dan Programming' started by ridhuan21, 28 Aug 2015.

?

query pencarian php

  1. php

    1 vote(s)
    100.0%
  2. query

    1 vote(s)
    100.0%
Multiple votes are allowed.
Thread Status:
Not open for further replies.
  1. ridhuan21

    ridhuan21 Beginner 1.0

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    permisi, saya member baru, mau tanya

    saya mau mencari data berdasar prodi (keterangan dibawah)

    select *
    from tbl_mhs where
    nim like '%41%'

    format nim kami
    1141053 (nyambung kl di datanya 1141053)
    11 th masuk
    41 prodi
    053 nomor urut

    kalau pakai sintak diatas
    misal nim
    1131041

    jd terikut juga, padahal yg saya cari

    2 angka di depan terserah sebelum 41 dan 3 angka di akhir terserah, cuma mau cari per prodi gitu maksudnya

    ada yg bisa kasih masukan? apa harus dipisah untuk nim nya
     
  2. masiqbal

    masiqbal Expert 2.0

    Messages:
    863
    Likes Received:
    249
    Trophy Points:
    43
    Kalau harus pakai LIKE:
    Code:
    select *
    from tbl_mhs where
    nim like '__41%'
    atau kalau memang sudah pasti nomor urut 3 digit
    Code:
    select *
    from tbl_mhs where
    nim like '__41___'
    Kenapa gak bikin kolom prodi aja, sehingga tidak perlu pakai LIKE ?
     
    ridhuan21 likes this.
  3. ridhuan21

    ridhuan21 Beginner 1.0

    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    trimakasih banyak,

    kl ditanya kenapa?, alasannya biar hemat database dan gak kebanyakan fild

    akhirnya bisa hitung jumlah prodi tanpa nambah fild

    terimakasih

    Select count(*) AS tix from tbl_wisuda left join (tbl_mhs) on tbl_wisuda.id_mhs=tbl_mhs.id_mhs WHERE thaj='$bts' and nim like '__43___'
     
  4. masiqbal

    masiqbal Expert 2.0

    Messages:
    863
    Likes Received:
    249
    Trophy Points:
    43
    Cuma satu field doang. Kalau pakai LIKE Anda menghemat space buat database, namun boros resource, karena LIKE '__43___' lebih berat bagi mysql dari pada prodi='43', apalagi nanti kalau datanya sudah semakin banyak.
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...