Hello to everyone i have a databse made up of 5 table, where 4 of the tables are linked to the fifth one by foreign keys.
the tables are as follows.

  1. Client - ClientID, ClientName
  2. Brand - BrandID, BrandName
  3. Currency - CurrencyID, CurrencyType
  4. RegisterShipments - RegShipmentID, ShipmentNo, ConsignmentNo,BDM,HUDINT,PAN

The following table has the above tables linked to it using Foreign Keys:
5. RegisterShipmentNoDetails - ShipmentDetailsID (PK), RegShipmentID(FK),CLinetID(FK),BrandID(FK),CurrencyID(FK), Season

What i would like to do is to be able to retrieve the data depending on shipment number chosen by user, as well as all the data of all the shipments that are present from the corresponding tables and display it in a datagrid.

I have come up with the following Select Statement, but it seem that it is not working as when i run the query in SQL it is giving me an error that Invalid object name 'RegisterShipmentNoDetails'. .

SELECT  Client.*,Brand.*, RegisterShipments.*, Currency.* from RegisterShipmentNoDetails
inner join RegisterShipments on RegisterShipmentNoDetails.RegShipmentID = RegisterShipments.ShipmentNo
inner join Client on RegisterShipmentNoDetails.ClientID = Client.ClientName
inner join Brand on RegisterShipmentNoDetails.BrandID = Brand.BrandName
inner join Currency on RegisterShipmentNoDetails.CurrencyID = Currency.CurrencyType 

Could someone please help me as i think that i might be doing something wrong in the select statement or else using the wrong Join. Thanks for any help.

Hi

Your query is joining ID columns against char columns which is incorrect (although I would have expected a different error than the one you mention). For example, INNER JOIN Client on RegisterShipmentNoDetails.ClientID = Client.ClientName is wrong, it should be RegisterShipmentNoDetails.ClientID = Client.ClientID and so on.

HTH

Hi dijeavons will check it out and see what will happen, will let you know if ok or not, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.