Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dragos95
Starting Member
3 Posts |
Posted - 2014-07-05 : 07:26:09
|
Hi.I have a little problem with INNER JOIN. I have learned from SQL for dummies 7th edition and I don't understand verry well, but I work in Access 2013. Can someone explain me where I'm wrong ? I want to select "CustomerID" from both tables, wich match with these conditions : Orders ( from customers ) > 50 and OrderType ( from orders ) = Big(P.S. : Sorry for my bad english )1. 2. 3. |
|
bitsmed
Aged Yak Warrior
545 Posts |
Posted - 2014-07-05 : 12:51:35
|
When joining tables you use "on" clause to tell the database engine, which fields are the same - in this case CustomerID.I use aliases alot on tables, which gives me the benefit of not having to write the whole tablename when referencing a field in a table. Also I can then join the same table several times. To do the alias thing, I use the "as" clause right after the tablename.You need to pay attention to spelling the fieldnames correctly. In your query you reference Order in the CUSTOMERS table. The correct fieldname is Orders.I'm guessing the OrderType field is a char or varchar field. If so, you need to put quotes around your filtering value ---> 'Big'.Your sql could look something like:select c.CustomerID from CUSTOMERS as c inner join ORDERS as o on o.CustomerID=c.CustomerID where c.Orders>50 and o.OrderType='Big' |
 |
|
dragos95
Starting Member
3 Posts |
Posted - 2014-07-06 : 05:10:59
|
Thank you ! |
 |
|
|
|
|