假设我有两张桌子:
- 学生:ID、姓名、年龄、班级等
- 条件:ID,条件
Column Conditions.Condition 包含一个 SQL 条件,例如“std.Age >2”或“std.Class = 3”
我想要执行以下操作的东西:
SELECT std.Id as StudentId, con.Id as ConId
FROM Students as std,
Condition as con
WHERE con.Condition
也许是一个需要学生 ID 的函数?
我如何实现这一目标?
学生:
1 , Yossi, 25, 3..
2 , David, 22, 3..
3 , Jhon, 5, 2..
4 , Smith, 25, 4..
条件:
1 , Age > 3
2 , Class = 4
3 , Name LIKE '%i%'
结果将是(条件,Studnet):
(1,1) (1,2) (1,3) (1,4) // all are older than 3
(2,4) // only Smith is in class 4
(3,1) (3,2) (3,4) // all except jhon have an i in their name