can't solve a homework problem for computer class. Any clues?: Given two tables, USERS and LOG, where USERID is a primary key in USERS and a foreign key in LOG, write a SQL statement that will return LOG records (all fields) with corresponding USERIDs in USERS. The report should include the LAST_NAME field from USERS and be sorted by user's last name, i.e., USERS.LAST_NAME

Thanks in advance for any help!

Recommended Answers

All 3 Replies

this is what i have so far:

SELECT * FROM LOG ORDER BY LAST_NAME DEC

...but I don't know how to incorporate the USERS table into it... confused

this is what i have so far:

SELECT * FROM LOG ORDER BY LAST_NAME DEC

...but I don't know how to incorporate the USERS table into it... confused

This is incorrect answer to your homework , you have to use thing like where userid='userid' ,etc .

let me give a sample schema and maybe that will help you understand

users
USER_ID
FIRST_NAME
LAST_NAME

log
LOG_ID
USER_ID
LOG_MESSAGE
LOG_DATE

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.