There is a table:
create table table1 (
id integer primary key,
user_id varchar(36),
field1 varchar(100))
How do I select the rows linked to the user, to which the row with a specific id belongs. I'd like to be able to look at the rows, choose a message by id and select all the rows, linked to the same user.
select * from table1
where user_id = -- the same as of the row with id = 3 for example
This is very easy with subqueries, in particular Comparisons Using Subqueries in the documentation:
SELECT * FROM table1 WHERE user_id = (SELECT user_id FROM table1 WHERE id = 3)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With