SOQL is used to query records from the Salesforce database. It includes clauses like SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, and LIMIT. The WHERE clause restricts rows returned using conditions, operators like equal, not equal, less than and logical operators. Relationship and aggregate functions can also be used. SOQL in Apex allows querying records in batches of 200 using for loops. SOSL performs full text searches across objects and includes clauses like FIND, IN, and RETURNING.