473,382 Members | 1,078 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,382 software developers and data experts.

two statments - same result ????

Syl
Hello! Can someone verify this for me please.

Should these 2 statments return the same result ? The 2nd one is the
original, the first one is my re-write. Thanks :

SELECT orders_status, paypalipn_txn . *
FROM orders
INNER JOIN paypalipn_txn ON item_number = orders_id
WHERE customers_id = 4417
ORDER BY date_purchased DESC LIMIT 1

and :

SELECT o.orders_status,p.*
FROM orders o
LEFT JOIN paypalipn_txn p on p.item_number = o.orders_id
AND o.customers_id = 4417 order by o.date_purchased desc limit 1

Dec 31 '06 #1
1 1240
It doesn't appear to be the same...

The INNER JOIN will return only orders that have a corresponding
paypalipn_txn record and belong to customer 4417.

The original LEFT JOIN returns all orders that belong to customer 4417.
If there's a paypalipn_txn record matching the join criteria, those
fields will be filled in, otherwise they will appear as NULL.

Some more info:

http://download-uk.oracle.com/docs/c...s7.htm#2054014
http://dev.mysql.com/doc/refman/5.0/en/join.html

Syl wrote:
Hello! Can someone verify this for me please.

Should these 2 statments return the same result ? The 2nd one is the
original, the first one is my re-write. Thanks :

SELECT orders_status, paypalipn_txn . *
FROM orders
INNER JOIN paypalipn_txn ON item_number = orders_id
WHERE customers_id = 4417
ORDER BY date_purchased DESC LIMIT 1

and :

SELECT o.orders_status,p.*
FROM orders o
LEFT JOIN paypalipn_txn p on p.item_number = o.orders_id
AND o.customers_id = 4417 order by o.date_purchased desc limit 1
Jan 1 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: jerrygarciuh | last post by:
Hi all, I am iterating through a result set to generate a second set of queries but no matter what I do I get the error Warning: mysql_num_rows(): supplied argument is not a valid MySQL result...
2
by: maceo | last post by:
I have a script that will print out the results of a table and make a calculation of a total of one of the columns. See example: <?php /* Database connection */...
5
by: Angelina | last post by:
Hi, I need some help in writing a 'if-then-else' statement. I currently have wrote one that looks something like this.. If Combobox1 = xxx and textbox1 <> "" then 'run stored procedure 1 to...
4
by: Jesper | last post by:
Hi, I would like to issue three statements to the database (mysql v4.1) each time the server starts up. Is there any built in way to do this? Like a init file to put them in? At the moment I...
4
by: Tao Wang | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I am quite confused on a equation, as following: #include <iostream> int main(){ int i = 2;
3
by: Vinny Vinn | last post by:
I have used simple batch statments with C#.for example: string select = "select model from cars where id = ?;select * from trucks where model = ?"; where ? is a parameter whose value i have...
5
by: orencs | last post by:
Hello, I am using Microsoft.Practices.EnterpriseLibrary.Data. I am running the following sqlCommand = "SELECT var1 FROM table1 WHERE var2 IN (4,5,6) ; SELECT var3 FROM table2 WHERE var2 IN...
2
by: lee | last post by:
Newbie question: I'm looking for the easiest way to run SQL statments in Access. I'm getting confused by th GUIs - I'm just looking forhow to run SQL on a table- thanks
2
by: ramdil | last post by:
Hi All Please help me .Hope i have described my problem clearly below. I have a condition where i need to update some data in table from the value taken from another table.So basically i need to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.