Jump to content

linking 6 tables - easy for some but not for me!


Guest carly494

Recommended Posts

Guest carly494

I am trying to query 6 tables at the same time, my manager is off so I have nobody to ask for help!!

 

My tables and fields are:

The numbers are the fields I can link them together with

 

T - stockdet

f - std_code (1)

f - std_desc

f - std_dep

f - std_lcost

f - std_rprice

f - std_defman (2)

 

T - branchcat

f - branch (3)

f - category (4)

f - cattype

f - minstock

f - maxstock

 

T - branchstock

f - bstk_branch(3)

f - bstk_stocklevel

f - bstk_onorder

 

T - supplier

f - man_code(2)

f - man_name

 

 

T - pchange

f - p_type

f - p_code(1)

f - p_band (4)

 

T - branch

f - branch(3)

f - name

 

 

 

If I run the below query I just get 'You have an error in you SQL syntax'

 

select std_code , std_desc , std_dep , std_lcost , std_rprice , man_name , minstock , maxstock,  lpad(bstk_branch,4,'0')  , bstk_stocklevel , bstk_onorder , branch.name , p_band

from stockdet

left outer join supplier on man_code = std_defman

left outer join pchange on p_code = std_code

left outer join branchcat on category = p_band

left outer join  branch on lpad(BRANCH.branch,4,'0') =  lpad(bstk_branch,4,'0')

left outer join branchstock on  lpad(bstk_branch,4,'0')  = lpad(BRANCHcat.branch,4,'0'

where P_type = 'C' 

 

 

Any help on this would be fantastic, I realise this may be a totally dumb question but I am new to SQL and as I said my manager is off today and there's nobody at work who can help.

 

Thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.