SQL [newbie]

J

Jon

The following query should sort the second field in ascending order:

SELECT Sales_Registration_Data.Date_of_Reg, [Manufacturer_ID] & "" AS Make,
Sales_Registration_Data.[Model&Variant_ID], Car_Model_Variants.[C:C], [Power]
& " " AS PWR, Sales_Registration_Data.Quantity,
Sales_Registration_Data.Registration_type,
Car_Model_Variants.AUX_Data_Input_Model_Entry
FROM Car_Model INNER JOIN (Car_Model_Variants INNER JOIN
Sales_Registration_Data ON Car_Model_Variants.[Model&Variant_ID] =
Sales_Registration_Data.[Model&Variant_ID]) ON Car_Model.Model_ID =
Car_Model_Variants.Model_ID
ORDER BY Sales_Registration_Data.[Model&Variant_ID];

However, somehow when I retrieve the values from within the query, not all
the values are being displayed for Sales_Registration_Data.[Model&Variant_ID].

ERD at
http://cid-b712073b3513eb8e.skydrive.live.com/self.aspx/.Public/relationships.docx
 
J

Jerry Whittle

The sort happens after the records are selected by the query. If you remove
the ORDER BY clause, all the same records should be returned. Therefore it's
not the sort causing records to go missing.

Instead I'm beating that it's the INNER JOIN(s). For all the records to be
returned with an INNER JOIN, there must be a matching record in the joined
table. Try turning the second INNER JOIN to a LEFT JOIN. If that doesn't
work, try a RIGHT JOIN.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top