Sum a specific range of numbers in a column using MYSQL
P粉821274260
2023-09-04 19:06:25
<p>I have a slider that calculates the BPM of a song. Range is 15 to 300 bpm. It connects to MySql database using php language and when I press edit button I can change its value. For example from 50 to 55bpm. table=users|columns=song_one. </p>
<p><code><input value="<?php echo $this->data->song_one;?>" name="song_one" type="range" min="15" max ="300" value="100 "Read-only>\</code></p>
<p>What I want is if I change the value below 15 and above 300, not accept it. How can I do this?
I've heard something about constraints..</p>
<p>I tried it, but it didn't work. </p>
<pre class="brush:php;toolbar:false;">ALTER TABLE users
ADD CONSTRAINT song_one CHECK (num >= 15 AND num <= 300);</pre>
<p>Any information would be very helpful, thank you</p>
This will work for you.