473,395 Members | 1,393 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Using PHP and MySQL query results.

thatos
105 100+
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
4 1432
Rabbit
12,516 Expert Mod 8TB
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
105 100+
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
105 100+
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
12,516 Expert Mod 8TB
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

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

Similar topics

4
by: John Victor | last post by:
In my php page I'm using a mysql database. I want to run a query on a table, then run a second query on the results returned from the first query. In mysql this would be the same as running a...
1
by: Guy Erez | last post by:
Hi, I'm running queries with MySql 4.0.17 that return thousands of records. Because I need to present them in GUI, I returieve the results in chunks using LIMIT, for example - get first 100,...
3
by: Shiriah | last post by:
I feel that this is a rather trivial concept that I cannot quite wrap my head around to make work in PHP. I consider myself an intermediate user in SQL (both MSSQL and MySQL) and somewhat novice in...
6
by: traineeirishprogrammer | last post by:
I am currently working on a project where I need to sort my MYSQL query results by different categories. How ever the code does not seem to be working properly and I spend too much time on it...
2
by: stmfc | last post by:
i have a problem with user creation for mysql db i think the problem stems from string style. GRANT ALL ON newDB.* TO 'test'@'localhost' IDENTIFIED BY 'test'; i am...
10
by: Lloyd Harold | last post by:
I'm very new to PHP and attempting to put together a simple script for retrieving MySQL data of personal records. The MySQL table I'm using consists of: 0: id 1: name 2: location (an integer...
1
Cowbie
by: Cowbie | last post by:
Hello again, I'm using a MySQL database and I want to pull results from the database and put them onto a php page. I've currently got it working using the following code, but it's not exactly what...
4
by: TechnoAtif | last post by:
Hi ALL I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be...
2
aas4mis
by: aas4mis | last post by:
I have a table that I want a,b,c,d,e,f,g,h,and m for headers and 26 rows. In the values I want to verify against a mysql query. If cell A3 is in the list I want to highlight it yellow (or put an X...
3
by: emsik1001 | last post by:
Hi http://dev.mysql.com/doc/query-browser/en/mysql-query-browser-connection.html I'm trying to connect from my Windows based PC to a dedicated server which is running on Linux system. I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.