---
schema_version: "1"
id: 25bb935adf10a8f8c032300b856c53ac56e5af50f177a3c919bba30c934e9520
title: Querying All Records with a SOQL Statement
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/langCon_apex_SOQL_query_all_rows.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_query_all_rows.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c8b148326a2343cded7d0843df490d8489a22066e6f1fcfa5de355bb74be8da8
---
# Querying All Records with a SOQL Statement

SOQL statements can use the ALL ROWS keywords to query all records in an organization, including deleted records and archived activities. For example:

Assert.areEqual(2, \[SELECT COUNT() FROM Contact WHERE AccountId = a.Id WITH USER\_MODE ALL ROWS\]);

You can use ALL ROWS to query records in your organization's Recycle Bin. You cannot use the ALL ROWS keywords with the FOR UPDATE keywords.

- [← Previous](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_variables.htm "Using Apex Variables in SOQL and SOSL Queries")