简体   繁体   中英

two tables and trying to access info from another table

I have a table called users and another called tickets

The users table has

id
firstName
lastName

the tickets table has the following fields

id
ticket
issuedTo
fine
user (numeric id that corresponds to the id field of the user table)
status

I am trying to design a query where I can find all the queries that were created by a specific person

SELECT tickets.*, user.firstname, user.lastname FROM tickets WHERE tickets.user INNER JOIN user.id AND user.firstname="John" AND user.lastname="Doe"

I tried the above but didn't work so there must be something wrong with my SQL Query. Please help

I am using a Microsoft Access Database 2007.

Try this

SELECT u.firstName, u.lastName, t.*
FROM users u INNER JOIN tickets t
    ON u.id = t.user
WHERE u.firstName = ???
  AND u.lastName = ???

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM