MySQL Query with Multiple Tables

后端 未结 3 1932
遥遥无期
遥遥无期 2021-01-21 02:16
Table: UserInfoTbl
=======================
| username  | type    |
=======================
| user0001  | premium |
| user0002  | premium |
| user0003  | normal  |
| user         


        
相关标签:
3条回答
  • 2021-01-21 02:54

    DroidMatt can you clarify what the 2 tables relationship are

    UserInfoTbl.username = UserPvTbl.fusername
    or
    UserInfoTbl.username = UserPvTbl.username

    Vikram is right assuming the first. otherwise you want this.

    SELECT *
    FROM UserInfoTbl, UserPvTbl
    WHERE UserPvTbl.username = UserInfoTbl.username
    AND UserPvTbl.username = 'user0003'
    
    0 讨论(0)
  • 2021-01-21 03:00
    select U.*
    from UserInfoTbl U
    inner join UserPvTbl UP
    on U.username  = UP.fusername  
    where UP.username = 'user0003'
    
    0 讨论(0)
  • 2021-01-21 03:05

    Use like :

    select * from UserInfoTbl inner join UserPvTbl on UserInfoTbl.username=UserPvTbl.fusename
    where UserPvTbl.usename='user0003'
    
    0 讨论(0)
提交回复
热议问题