SQL Select statement help please (1 Viewer)

shabbaranks

Registered User.
Local time
Today, 12:37
Joined
Oct 17, 2011
Messages
300
Hi guys,

I cant get my head around what appears to be a simple sql select statement and was wondering if someone can help me please?

I have 2 tables table 1 has all the data Im after but is linked to table 2 by a Request_ID Field. They say a picture paints a thousand words so:



So basically Im trying to fill in the gaps with a report which lists the material correlating to the Material_Req and the other fields which relate to that. If that makes sense?

Thanks as always
 

sneuberg

AWF VIP
Local time
Today, 04:37
Joined
Oct 17, 2014
Messages
3,506
What have you tried? Seem like a simple join between the tables would do what you want.

Why is Material in both of these tables. From a normalization standpoint that doesn't look right
 

shabbaranks

Registered User.
Local time
Today, 12:37
Joined
Oct 17, 2011
Messages
300
Material is on both tables because its part of a transaction table so some values are null others are the material.

Ive tried an inner join which doesn't work. I was thinking create two separate queries and then union joining them but that doesn't work either.
 

sneuberg

AWF VIP
Local time
Today, 04:37
Joined
Oct 17, 2014
Messages
3,506
Given the sample data an inner join on Material Req should at least produce the two records where they are equal to 8690 albeit there isn't any interesting data in table1. How is this type of join not working? Could you upload a copy of your database with these two tables and the query you have tried?
 

shabbaranks

Registered User.
Local time
Today, 12:37
Joined
Oct 17, 2011
Messages
300
I only want to show the values within table1 but use the material values which are stored within both tables to get the results and (as you can with Access) create a field which displays the material name because obviously the material is null within table1.material which equals table2.material_req.

Unfortunately I cant upload upload the database but if necessary I could create a couple of tables within access which simulates the tables if necessary? But Im trying to do this is MSSQL.

Thanks
 

Users who are viewing this thread

Top Bottom