MySql数据库查询解决方案?

时间:2016-12-22 17:07:38

标签: mysql

我的数据库中有两个表说'si'和'gi',两个表中都有数字列说regno,我想从两个表中获取数据。

我正在使用这个Mysql查询

select * 
from si 
join gi on(si.regno=gi.regno) 
where regno=1" 

并显示regno不明确。

对此的正确查询是什么?

2 个答案:

答案 0 :(得分:0)

像这样构建您的查询: 尝试

SELECT 
        *
    FROM 
        si
    INNER JOIN 
        gi 
    ON
        si.regno=gi.regno
    WHERE 
        where regno=1

答案 1 :(得分:0)

where 子句中有错误,因为哪个regno列来自哪个表  , si gi

更改您的查询

select *  from si join gi on(si.regno=gi.regno) where si.regno=1"

select *  from si join gi on(si.regno=gi.regno) where gi.regno=1"