Home > Net >  how to show only multiple of 25 in a sql record?
how to show only multiple of 25 in a sql record?

Time:11-07

enter image description here

I have a plenty of record in MedicineStock field. i would like to only show the multiple of 25 in MedicineStock.. multiple of 25 [ 50 - 75 - 100.. etc ]

here's query i try

SELECT MedicineID,MedicineName,MedicineStock
FROM c a, MsMedicineType b
WHERE a.MedicineTypeID = b.MedicineTypeID
AND MedicineStock = MedicineStock 25
ORDER BY MedicineName

but it's not working. i'm still student i try to read the modules the teacher give.. but don't find any good refreence for it. and already looking for some refreence in google and couldn't find it. i'm totally stuck. i hope i'll get to know how to do it. in here. thank you in advance

CodePudding user response:

Use the MOD function which represents the modulus operation in math. MOD() returns the remainder of a number divided by another number, in your case, all multiples of 25 have 0 as remainder.

SELECT MedicineID,MedicineName,MedicineStock
FROM c a, MsMedicineType b
WHERE a.MedicineTypeID = b.MedicineTypeID
AND MOD(a.MedicineTypeID,25) = 0
ORDER BY MedicineName
  • Related