By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 671 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

Using PHP and MySQL query results.

thatos
100+
P: 105
I have two results which I got after performing two and I want to left join those two tables, will this work. e.g.

[code]
$query1 = "select sample__code, location from sample";
$query2 = "select sample_code, value from ion_data where ion_id = 1";
$result1 = mysql_query($query1);
$result2 = mysql_query($queyr2);

//How do I perform a left join between the two

//or will this work
$query = '( $query1 left join $query2 where sample.sample_code = ion_data.sample_code)';
Oct 1 '11 #1
Share this Question
Share on Google+
4 Replies


Rabbit
Expert Mod 10K+
P: 12,359
You can just write one sql string with the left join. There's no need to separate them and then try to join them afterwards.
Oct 1 '11 #2

thatos
100+
P: 105
But for ease of use can't I just have different statements and then concatenate those strings to form the final query?
Oct 2 '11 #3

thatos
100+
P: 105
Or it this possible.
Expand|Select|Wrap|Line Numbers
  1. $query = "(select s,m from R left join select s,n from P where R.s = P.s) left join select s,p from A where ?.s = A.s";
  2.  
Oct 2 '11 #4

Rabbit
Expert Mod 10K+
P: 12,359
That's not syntactically correct SQL so no, you can't use that exactly. But in concept, you can do that.
Oct 3 '11 #5

Post your reply

Sign in to post your reply or Sign up for a free account.