PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

SQL · Theory

String

← All stacks

Theory

131/439

String

String functions work on VARCHAR/CHAR/TEXT: CONCAT, SUBSTR, TRIM, UPPER, LENGTH. SELECT UPPER(name), TRIM(city) FROM students;

They return a new value. The table does not change until UPDATE. Indexes start at 1.

LENGTH is bytes; CHAR_LENGTH is characters (utf8mb4). CONCAT with NULL becomes NULL unless you use CONCAT_WS or IFNULL.

Trap: using string functions in WHERE on a huge indexed column (UPPER(name) = 'ASHA' may skip the index). Prefer storing canonical form.

On the example next to this theory: String: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Exam tip

Name CONCAT / TRIM / UPPER and one students example.

String — sample query

-- String
CREATE TABLE demo (
  id INTEGER PRIMARY KEY,
  label TEXT NOT NULL,
  qty INTEGER DEFAULT 0
);
INSERT INTO demo (id, label, qty) VALUES
  (1, 'alpha', 2),
  (2, 'beta', 5);
SELECT label, qty FROM demo WHERE qty >= 2 ORDER BY qty DESC;

String: create two demo rows, then SELECT qty >= 2 ordered. Say which labels come back.

Short notes

  • DefString functions transform text in SELECT.
  • Rule1-based indexes. CONCAT + NULL = NULL.
  • TrapUPPER(col) in WHERE on a big table.

Questions

1

Name three string functions.

131 / 439

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.