Mysqli select from from two tables
问题 I have data stored in two different tables called "posts" and "comments". Now i'm using two mysqli_query. $q = mysqli_query($db,"SELECT * FROM posts WHERE username='$username'"); $q = mysqli_query($db,"SELECT * FROM comments WHERE username='$username'"); Can I make this with only one mysqli_query or with 3 tables? 回答1: You can simply join both tables: $q = mysqli_query($db,"SELECT * FROM posts LEFT JOIN comments ON comments.username=posts.username WHERE comments.username='$username'");