Mysql主键、外键运用于关联查

    xiaoxiao2021-03-25  105


    8.Mysql多表查询

    1.user表 2.message表 目标:只知道username=‘tom’查询出tom的phone sql;SELECT phone FROM user u, message m WHERE u.id=m.userid AND username=’tom’; 结果: 3.infom表 三张表连接查询 目标:只知道username=‘tom’查询出tom的infom的信息 sql:select infom from user u ,message m, infom i where u.id=m.userid and u.id=i.infomid and username=’tom’; 或者: aql:select infom from user u ,message m, infom i where u.id=m.userid and m.userid=i.infomid and username=’tom’; 结果:

    转载请注明原文地址: https://ju.6miu.com/read-23159.html

    最新回复(0)