mysql_query check for value range multiple times
NickName:Matthias Müller Ask DateTime:2013-11-02T21:45:50

mysql_query check for value range multiple times

I need to check for value range multiple times, this is how i do it till now:

<?php
$preischeck = mysql_query("SELECT preis FROM outfits WHERE aktiv = 'ja' and preis <= 100 $marke $farbe");
if(mysql_num_rows($preischeck) > 0) {
     echo "0 - 100 is there";
}
?>
<?php
$preischeck = mysql_query("SELECT preis FROM outfits WHERE aktiv = 'ja' and preis > 100 and preis <= 200 $marke $farbe");
if(mysql_num_rows($preischeck) > 0) {
     echo "100 - 200 is there";
}
?>

And so on.. I guess this is too much for the server and there is a better way. Any ideas?

Copyright Notice:Content Author:「Matthias Müller」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/19742534/mysql-query-check-for-value-range-multiple-times

Answers
Peter van der Wal 2013-11-02T13:58:36

Why don't you just use an GROUP BY in your SQL-query:\n\nSELECT preis FROM outfits GROUP BY preis\n\n\nIf you want 100-blocks\n\nSELECT FLOOR(preis / 100) * 100 FROM outfits GROUP BY FLOOR(preis / 100)\n\n\nThen if 0 is in your resultset you know that 0 - 99,99, if 100 in your resultset 100-199,99 is there etc.",


More about “mysql_query check for value range multiple times” related questions

mysql_query check for value range multiple times

I need to check for value range multiple times, this is how i do it till now: &lt;?php $preischeck = mysql_query("SELECT preis FROM outfits WHERE aktiv = 'ja' and preis &lt;= 100 $marke $farbe"); if(

Show Detail

why mysql_query executes multiple times

i have a function and an update query in it like this : //Article Function function article() { if($_GET['action'] == "article" &amp;&amp; !empty($_GET['id'])) { $id = intv

Show Detail

Repeat range of items multiple times in Google Sheets

I want to repeat the range of items multiple times (Value provided). e.g. I have this in a sheet1!A Detroit Texas Utah California Now I want to repeat them 3 times to get the output at Sheet2!A

Show Detail

If a range contains certain value multiple times, paste the cell next to it in specific cells

I have code to check through a range for a cell value, and then paste the cell to the left in a different location. HOWEVER, I can not seem to figure out what to do if the range contains a value mu...

Show Detail

SQL Check if value is between multiple times periods

I'm trying to setup a query to check if the date/time from my record is within a valid time and not during a scheduled break. I have a table that has multiple start/end times for break start/end ti...

Show Detail

Check if a value is within a range of numbers

I want to check if a value is in an accepted range. If yes, to do something; otherwise, something else. The range is 0.001-0.009. I know how to use multiple if to check this, but I want to know if...

Show Detail

Value exists multiple times in a range, Need to extract corresponding row values

I am a learner in Excel and I love learning new things. A value exists multiple times in a range say B2:Z20.Value does not duplicate in a row i.e it is present only one time in a row in this range...

Show Detail

Inserting range to another sheet as rows multiple times

I am trying to copy range from sample reference card into another sheet and insert this range as row on above existing ones, multiple times. Right now I have code that is working for inserting this...

Show Detail

How to check a value in a list value range in python

I have a value to check in the list range Example: recipies = int(input("enter:")) print(recipies) interval =[] for i in range(recipies): x = (input().split()) interval.append(x) print(

Show Detail

how to check if a value in a column exists in same column multiple times in a pandas dataframe

My problem statement is that I want to check if a value in a column in a pandas data frame occurs for multiple times or not. How can that be done? I am thinking of applying two for loops and someth...

Show Detail