1

I have 2 tables named as master and kpi.
Master table has following columns

no, name, dtStart, dtEnd, status, user and dtCreate

kpi table has following columns

no and kpName

"no" in kpi table refers "no" in master table

What i expect to do is, when I select a name from the dropdownlist relevant details in both tables should be displayed.
One name has unique "no". Also "no" can have multiple kpNames.
Please help me.

3
  • 1
    Please tell us the relationship between these two tables, ideally along with some sample data. Commented Oct 26, 2016 at 10:01
  • 1
    Add some sample table data, and the expected result. (As well formatted text.) Commented Oct 26, 2016 at 10:02
  • 2
    Lookup INNER JOIN Commented Oct 26, 2016 at 10:02

3 Answers 3

2

try this:

SELECT a.[no], a.name, a.dtStart, a.dtEnd, a.[status], a.[user] , a.dtCreate 
From masterTable  a 
Inner JOIN kpiTable b ON a.[no] = b.[no]
Where b.Name = 'dropDownSelectedValueName'
Sign up to request clarification or add additional context in comments.

1 Comment

as mentioned, u can create a stored Procedure and call it on every time drop down selection change, it has its own advantages.
2

You have to make a stored procedure and then join both tables. Here is sample

create proc Details
begin
@Name char(50)
select * from Master m join kpi n ON
 m.no==n.no where Name== @Name
end

Comments

1
SELECT table1.[no], table1.name, table1.dtStart, table1.dtEnd, 
table1.[status], table1.[user] , table1.dtCreate ,table2.kpName 
FROM masterTable [table1] 
INNER JOIN kpiTable [table2] 
ON table1.[no] = table2.[no] 
WHERE table2.Name = 'Your Selected value'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.