I am new to sql. Have been programing for a while but have always found a way not to use databases. I know stupid.
I have a questions about One to Many sql queries.
I am building a website so i can understand databases a little bit more. So what i have is one database with 2 tables. One holds the user information and the holds the the hardware for that user. There an be only one user but there can be multiple pieces of hardware for that user. I can write the query to display the user information no problem. What i can't seem to get my head around is how to write the query to get relate all the hardware to that user and display it.
here is my example of tables
user table
user_id ------ primary key
first_name
last_name
hardware table
hardware_id ---- primary key
serial
model
type
user_id ---- foreign key (link to the user table)
example
user table
user_id first_name last_name
01 John Doe
02 Jane Doe
hardware table
hardware_id serial model type user_id
01 cac21 Dell Desktop 01
02 cac22 HP Laptop 01
03 cac24 Apple Laptop 02
Any help would be great.
Thanks GG