Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在sql中比较列与列_Php_Sql - Fatal编程技术网

Php 在sql中比较列与列

Php 在sql中比较列与列,php,sql,Php,Sql,我有两个表,'student'和'teacher'。'student'有两列'roll','class'。'teacher'也有两列'id','class'。我想从'student'表中获取'roll'列的一些值,其中'class'列的某些值将与'teacher'表的'class'列的值匹配。你能给我一个解决方案吗 **student** **teacher** roll class id class 1 on

我有两个表,'student'和'teacher'。'student'有两列'roll','class'。'teacher'也有两列'id','class'。我想从'student'表中获取'roll'列的一些值,其中'class'列的某些值将与'teacher'表的'class'列的值匹配。你能给我一个解决方案吗

**student**              **teacher** 
roll     class           id       class

1         one            101       one
2         three          102       three
3         five           103       four
从学生名单中选择滚动 内部连接教师T在S.Class=T.Class上

SELECT
    student.roll
FROM
    student
    INNER JOIN teacher ON student.class = teacher.class