Table: UserInfoTbl
=======================
| username | type |
=======================
| user0001 | premium |
| user0002 | premium |
| user0003 | normal |
| user0004 | premium |
=======================
Table: UserPvTbl
========================
| username | fUsername |
========================
| user0003 | user0002 |
| user0002 | user0001 |
| user0003 | user0001 |
========================
How can I select all the information from UserInfoTbl where fUsername of UserPvTbl has username of user0003?
Edit: Meaning that I need to retrieve information of user0002 and user0001 from the UserInfoTbl
Edit2: Relationship between both tables : UserInfoTbl.username = UserPvTbl.username
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'
Use like :
select * from UserInfoTbl inner join UserPvTbl on UserInfoTbl.username=UserPvTbl.fusename
where UserPvTbl.usename='user0003'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With