fetch users from table 1 by searching in table 2?

Roger Rhode :

I have this table called experience the columns are

id   |  userid  |  expid
1       2          3
2       2          4
3       2          8
4       1          4
5       6          4

how do i fetch users from table called users with column userID matching expid from table experience?

so far i have this but need help with the sql query to see results?

<?php
$action = $_REQUEST['action'];
 $exp = $_POST['exp'];
if($action=='experience_search'){
foreach ($exp as $fetch){
    echo $fetch."<br />";


    }
?>  

thanks a ton

invalid bot :

This where the MySQL Join is applicable.

Assume that you want to get the first_name of the user from the users table matching expid 8.

SELECT experience.*, users.first_name FROM experience
JOIN users on users.id = experience.user_id
WHERE experience.expid=8

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=33331&siteId=1