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

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
venkateshb
Forum Newbie
Posts: 3
Joined: Thu Mar 26, 2009 3:36 am

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

Post 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.
Last edited by Benjamin on Sun May 17, 2009 2:00 am, edited 1 time in total.
Reason: Added [code=sql] tags.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

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

Post by Benjamin »

:arrow: Moved to Databases
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

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

Post 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.
Post Reply