Click here to Skip to main content
15,915,763 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi
I have many tabels I want to join them to fill a gridview:

OperatingAreas: OANo,OAName
Subarea:subarea_id,name.OAName
Substation:substation_id,name,subarea_id
Equipments_Class:equipment_class_id,name
Equipmen_Name:equipment_name_id,name,equipment_class_id,substation_id

I have gridview display the names of Area,Subaarea,Substation,EqipClass & EquipName
(depends on mean many to 1)
Subarea depends on OperatingAreas
Substation depends on Subarea
Equipment_Name depends on Substation & Equipment_Class

My query in vb.net:
SQL
"select a.OAName as Area, s.Name as Subarea, ss.Name as Substation, eqc.Name as Equipment_Class, eqn.Equipment_Name_id, eqn.Name as Equipment_Name from Equipments_Names as eqn, " _
& " OperatingAreas as a INNER JOIN Subarea as s on a.OANo = s.OANo INNER JOIN Substations as ss on ss.Subarea_id = s.Subarea_id " _
& " INNER JOIN Equipments_Class as eqc on eqc.Equipment_Class_id = eqn.Equipment_Class_id"


the query not works because table name Equipments_Names table I don`t knowhow to implement the query at correct way

My frind told use use 2 queries one for Equipments_Class with Equipments_Name and the second one for Substations with Equipments_Names in a rowdatabound in gridveiw (as 2 datatables)

but I want make them in 1 query or in other word one datatable like join 2 queries in one query.

Any help?
Thank you
Posted
Comments
ITTIHAD FC. 28-Apr-14 1:30am    
there is no relation between Equipments_Class & Substation
Maciej Los 2-May-14 18:13pm    
If there no relation between them, how could it be possible to join them in one query? Based on waht condition?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900