Sum a specific range of numbers in a column using MYSQL
P粉821274260
P粉821274260 2023-09-04 19:06:25
0
1
626
<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>
P粉821274260
P粉821274260

reply all(1)
P粉106711425

This will work for you.

ALTER TABLE users
    MODIFY COLUMN song_one INT CHECK (song_one >= 15 AND song_one <= 300);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!