KnowledgeBoat Logo

Computer Science

With SQL, how do you select all the records from a table named "Persons", where the value of the column "FirstName" ends with an "a"?

  1. SELECT * FROM Persons WHERE FirstName = 'a';
  2. SELECT * FROM Persons WHERE FirstName LIKE 'a%';
  3. SELECT * FROM Persons WHERE FirstName LIKE '%a';
  4. SELECT * FROM Persons WHERE FirstName = '%a%';

SQL Queries

1 Like

Answer

SELECT * FROM Persons WHERE FirstName LIKE '%a';

Reason — The SQL query SELECT * FROM Persons WHERE FirstName LIKE '%a'; retrieves all records from the "Persons" table where the "FirstName" column ends with "a". The LIKE keyword with "%" as a wildcard matches any characters preceding "a".

Answered By

3 Likes


Related Questions