0

I got a PHP script that I need to run several queries of the same thing just different parameters, like:

SELECT * 
FROM Weather_records 
WHERE type = 1, 

SELECT * 
FROM Weather_records 
WHERE type = 2

Is there a way to run this as one query and just put it in a array or something?

2
  • there are several ways, depending on what you want to achieve. From views, a loop, a where type IN, ... too many options and possibilities here! Commented Jun 22, 2017 at 0:50
  • its for view, I know I could just use a loop but I'm doing like 12 quarries Commented Jun 22, 2017 at 1:10

2 Answers 2

6

Use IN

SELECT * FROM Weather_records WHERE type IN (1,2)
Sign up to request clarification or add additional context in comments.

2 Comments

For ranges you can do WHERE type BETWEEN 1 AND 2.
Well I will need to do something with each record. So how do I take this query and get each record from it separately?
0

I was looking at the problem wrong and ended up using one query to get the whole table and then used a loop and a switch case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.