Get Auto Foreign Key value

I am trying to do a generalized basic search for my MS-SQL data. Let me explain what I have done so far:

  • First, I fill in one field with all the table names.
  • Then fill in the second combo box with the columns of the selected table from the first combo box.

I am running a generic database query for example select * from combobox1.text where combobox2.text='someValue'

. Everything works fine for me, but I cannot get foreign key data that is primary in another table.

What I need

suppose Table A has columns: 1 primary key, 2 id name. And Table 2 with: 1 as the primary key column, 2 as the address column, and 3 as the foreign key column. When I runselect * from table2

I am getting the foreign key result in terms of id, I want the value of the table1.2 column.

Why i ask

This is because with this type of system, I can query every row in the database without having to manually code for every table.

Pictures for a better explanation

Workshop employee table Employee Master Table

Attendance table

Attendance Table

The result I want Result table

+3
sql database sql-server primary-key foreign-keys


source to share


No one has answered this question yet

Check out similar questions:

2603
Add column with default value to existing table in SQL Server
1657
Finding duplicate values ​​in a SQL table
960
Insert into ... values ​​(SELECT ... FROM ...)
764
How can foreign key constraints be temporarily disabled using T-SQL?
595
Reset credential seed after deleting records in SQL Server
281
How do I select rows without a matching record in another table?
82
Foreign key referring to primary keys in multiple tables?
66
Primary Key / Foreign Key Assignment Convention
60
Add foreign key relationship between two databases
0
Foreign key error in SQL Server


Loading...
X
Show
Funny
Dev
Pics