0

Is it possible to retrieve elements from multiple SELECTS into PHP?

Take this one for example:

$query= mysql_query("SELECT ...; SELECT ...;") 

If it is possible how can we organize the information ?

I don't think it's as simple as:

while($row = mysql_fetch_array($query))
3
  • 1
    does your select have the same columns retrieve? what are you trying to do? Commented Oct 24, 2012 at 1:17
  • 1
    it's hard to tell what you want to do. Is it a Union of two selects? Commented Oct 24, 2012 at 1:24
  • 1
    if they relate you can Inner, left, full outer join these data together. If they don't you can still join them together using a cross join which gives you all records from both joined tables. Understanding your table structures is imperative to provide a response though. Commented Oct 24, 2012 at 1:43

2 Answers 2

1
$query = mysql_query("SELECT [blank] FROM [blank]
UNION
SELECT [blank] FROM [blank]");

(what the previous people suggested, just how it'd look)

Sign up to request clarification or add additional context in comments.

Comments

1

You should use Union as @JLibert suggested.

See documentation: http://dev.mysql.com/doc/refman/5.1/en/union.html

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.