Question:
Have to run a Cross Join in SQL where a value is NULL?
junicume
2012-10-30 15:01:32 UTC
I have to compare results using two different SQL commands. One with a join statement and one without. I got the command without the join statement to work:

SELECT ord.ORDER#, cust.LASTNAME, cust.FIRSTNAME
FROM ORDERS ord, CUSTOMERS cust
WHERE ord.SHIPDATE IS NULL
AND ord.CUSTOMER# = cust.CUSTOMER#
ORDER BY ord.ORDERDATE;

but can't get the command WITH a join statement to work. Help, please?
Three answers:
Zak
2012-10-31 01:05:46 UTC
I agree with Thread7's answer. You won't need LEFT JOIN though, just JOIN.



LEFT JOIN is a left outer join, and by default JOIN is a cross (or inner) join.



Thread7, if you see this, I refer to this diagram all the time: http://www.codinghorror.com/blog/2007/10/a-visual-explanation-of-sql-joins.html



Remember that by default, MySQL JOIN is an inner (or cross) join, LEFT JOIN is also called LEFT OUTER JOIN (and same for RIGHT JOINs).
Thread7
2012-10-30 15:09:06 UTC
I'm not a SQL expert but this is how I would write it:

SELECT ord.ORDER#, cust.LASTNAME, cust.FIRSTNAME

FROM ORDERS ord LEFT JOIN CUSTOMERS cust ON ord.CUSTOMER# = cust.CUSTOMER#

WHERE ord.SHIPDATE IS NULL

AND ord.CUSTOMER# = cust.CUSTOMER#

ORDER BY ord.ORDERDATE;



Maybe it shouldn't be a LEFT join, but INNER JOIN or RIGHT JOIN. I'm not 100% sure in your case.
niang
2016-12-24 23:17:00 UTC
As somebody who ran fairly nicely in extreme college and nonetheless run to as we communicate, i will permit you comprehend which you will get extra effective. 8:40 isn't a bad mile time the two. All you're able to desire to do is put in the miles week in and week out and you will see the seconds or perhaps minutes fade off that component. advantageous many human beings have a organic working skill, however the final public of pass u . s . runners put in the attempt to get the place they are. believe me, connect and artwork annoying, and in case you start up out tough, so does each and every person purely save attempting and attempting. I joined getting into to 11th grade so as long as you artwork annoying you will not have a concern. Oh and as an advantage, on the tip of the 300 and sixty 5 days you would be interior the final shape of your existence...and seem super to boot!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...