SQL question, joins and subqueries?
-
3. For each order, display the OrderID, ShipName, and the Employee First and Last Name. Order the results by Employee Last Name in descending order, then by Employee First Name in ascending Order, then by OrderID in ascending order. 830 rows returned. SELECT a.orderID,a.ShipName,b.Firstname,b.Lastn… FROM Orders AS a inner join Employees AS B ON a.EmployeeID=b.EmployeeID ORDER BY lastname DESC,FirstName ASC, OrderID ASC 4. Modify the first query to list the orders with customer details, but include all customers even if they have not placed an order. I looked at the actual customer details tab and it showed no null values from customers not placing an order, am I missing something? It just shows the same number that I get by doing the first query but it is supposed to add two to it, but I do not see the two in the table that it could pull up. I did select * from orders to see what was there, and the null value ones do not come up as existing. I know I have to be missing something but not sure what. Thanks for the help guys.
-
Answer:
Inner joins do not show nulls. With an inner join the matched columns must match each other or that record is left out. An outer join will bring everything including nulls. If what column your matching on doesn't match it includes that row anyway.
tedead at Yahoo! Answers Visit the source
Other answers
This SQL tutorial may help you to learn Joining tables and sub queries:
Sovandara
Explicit join operations: http://www.sql-tutorial.ru/en/book_explicit_join_operations.html
Serge M
hi Heather... learn outer joins please (left join, right join). the answer is there :) here's the link which i found via google : http://www.w3schools.com/sql/sql_join_left.asp
nicefx
Related Q & A:
- How To Repair Sql Database?Best solution by Ask.com old
- Are SQL Injection vulnerabilities in a PHP application acceptable if mod_security is enabled?Best solution by Programmers
- How can I optimize this dynamic SQL query in oracle with PL/SQL?Best solution by docs.oracle.com
- How to remove your question from yahoo question/answers?Best solution by Yahoo! Answers
- How to remove a question in the ask question editor?Best solution by Meta Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.