[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1729
  • Last Modified:

SELECT first record

I have a simple subquery in an Oracle SQLPLUS SELECT, but it returns > 1 records.
How do I  select only the first or top record?


0
vd
Asked:
vd
  • 2
1 Solution
 
ser6398Commented:
select *
from my_table
where rownum <= 1
0
 
ser6398Commented:
other options in a subquery:

select *
from my_table1
where id = (
  select max(id)
  from my_table2
            );


or


select *
from my_table1
where id IN (
  select id
  from my_table2
     );


0
 
vdAuthor Commented:
Thanks!
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now