从一个表中选择id在另一个表中,并用不同于第二个表的char替换整数

I have two tables, one is a user log which stores the user by number

timestamp / user_id / transaction_id / amount

the other is a user table which has the users number and their full name

user_id / fullname

I want to select the entire user log and display it, but instead of displaying their number, display their full name from the other table, but I can't get it working. I keep modifying the sql and breaking it. Is there a way to accomplish this with php postgresql or should I use a function? I keep getting an error that user_id is integer and the fullname is not Please assist.

    $query = "SELECT * FROM user_log 
    INNER JOIN user_staff
ON user_log.user_id=user_staff.user_name
ORDER BY user_log_id DESC LIMIT 200;";

    $result = pg_query($query); 
    if (!$result) { 
        echo "Problem with query " . $query . "<br/>"; 
        echo pg_last_error(); 
        exit(); 
    } 

    while($myrow = pg_fetch_assoc($result)) { 
        printf ("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $myrow['timestamp'], htmlspecialchars($myrow['user_id']), htmlspecialchars($myrow['transaction_id']), htmlspecialchars($myrow['amount']));
    } 
    ?> 

Perhaps something like:

SELECT user_log.timestamp, users.fullname, user_log.transaction_id, user_log.amount
FROM user_log
INNER JOIN users
ON users.user_id=user_log.user_id 
ORDER BY user_log_id 
DESC LIMIT 200;

You can read up on SQL Joins here: http://www.w3schools.com/sql/sql_join.asp

Use this query:

SELECT "timestamp", fullname, transaction_id, amount
FROM user_log
JOIN users USING (user_id)

Note that "timestamp" is a SQL reserved word and you should not use it for a column name. If you must use it, put it in double quotes.