Page 1 of 1

How to match set of sql queries in the t1 with data in t2

Posted: Sun May 17, 2009 12:25 am
by venkateshb
How to match set of sql queries in the table1 with data in the table2?
Table1:
Serial no. Column1
1

Code: Select all

SELECT * FROM Table2 WHERE Name=’A’ AND Age=20
2

Code: Select all

SELECT * FROM Table2 WHERE Name=’A’ AND Marks=100
3

Code: Select all

SELECT * FROM Table2 WHERE Name=’B’ AND Age=21
4

Code: Select all

SELECT * FROM Table2 WHERE Age=20 AND Marks=75
5

Code: Select all

SELECT * FROM Table2 WHERE Name=’A’ AND Age=21
* Column1 –Varchar
Table2:

Dept. No Name Age Marks
100 A 20 75

Requirement:
Table1 with column of varchar contains set of SQL queries. Table2 contains data. Need to get all the SQL queries from the table1 which are matching to a particular data in the table2.

Result Expected:
Need a sql query which returns the following result.

Code: Select all

SELECT * FROM Table2 WHERE Name=’A’ AND Age=20

Code: Select all

SELECT * FROM Table2 WHERE Age=20 AND Marks=75


Question:

Table1 with column of varchar contains set of SQL queries. Table2 contains a record data. Need to get all the SQL queries from the table1 which are matching to a particular record data in the table2.

I know, I can get all the SQL queries in the table1 by executing each SQL query string one by one against the table2 record data by using database procedures.
I am afraid, if I have thousands of SQL queries in the Table1 and fire each query one by one with the table2 record data, may cause latency and performance bottleneck.

Please refer the attached document.

How do we do this efficient way?

Any suggestion, experts help us.

Re: How to match set of sql queries in the t1 with data in t2

Posted: Sun May 17, 2009 2:03 am
by Benjamin
:arrow: Moved to Databases

Re: How to match set of sql queries in the t1 with data in t2

Posted: Sun May 17, 2009 6:51 pm
by califdon
You have a table that stores SQL queries? Would you show us what one of those records looks like? I am not understanding what you are trying to do, but I don't think it's what you are saying.