I am trying to select * from an oracle table, but only where user_id are unique.
i tried this:
select distinct user_id from users; -- which worked
i want to display EVERYTHING, so when i put:
select distinct user_id, * from users; -- i get a syntax error
how can i accomplish his?
select distinct user_id, users.* from users;
select * from users where users.primary_key IN
(select primary_key FROM users GROUP BY user_id HAVING count(*) = 1)
This will only select records that do not share user_ids with other rows.
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