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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Conditional Query

Author  Topic 

samsql
Starting Member

6 Posts

Posted - 2001-02-17 : 19:31:55
This is regarding to data retrival from different tables w.r.t to the ids in the main table.

Here is the scenrario.
The main table say ADVT has these fields.and the data is like this.
_________________________________________
Advt_ID ,Section_ID,AdType_ID,P_Title_ID|
_________________________________________
1 1 1 1
_________________________________________
2 1 1 2
_________________________________________
3 2 2 1
________________________________________
4 3 4 1
_________________________________________
5 4 5 Null
________________________________________


So the result set should read all advt_ID give details from respective section table depending on section_ID for that record.

Supose if for Advt_ID of 1 having section_ID of 1 which has P_Title_ID of 1,then it shoild read from Manufaturer section table Name field for manufacturer_ID = P_title_ID value.

So if the section_ID is same but P_Title_ID is different for a difffernt Advt_ID,then it will read that record from manufacturer table where the P_title_Id = manufacturer_ID.

Section_ID = 1 then it will read from manufacturer table the name field.
if section_ID =2 then it will the read from product table the name field for that corresponding P_title_ID.

Suppose if an ADVT_ID has P_Title_ID = Null,then it will read Ad_Desc from AdType table where in that AdType_ID in the ADVt tbale for that advt matches with AdType table.

Hope I made my question clear and Hope the experts here will guide me in getting a solution to this conditional query.

Advance thanks for your support.

Have a nice week -end.

Sam.

Samsql
   

- Advertisement -