0
0
SQLquery~5 mins

String quoting and concatenation differences in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What type of quotes are used in SQL to represent string literals?
Single quotes (' ') are used to represent string literals in SQL. Double quotes (" ") are typically used for identifiers like column or table names.
Click to reveal answer
beginner
How do you concatenate two strings in standard SQL?
You use the double pipe operator (||) to concatenate strings in standard SQL. For example: 'Hello' || ' World' results in 'Hello World'.
Click to reveal answer
intermediate
What happens if you use double quotes around a string in SQL?
Double quotes are used for identifiers, not strings. Using double quotes around a string will make SQL treat it as a column or table name, which can cause errors if that identifier does not exist.
Click to reveal answer
intermediate
How do MySQL and PostgreSQL differ in string concatenation?
PostgreSQL uses the || operator for string concatenation. MySQL uses the CONCAT() function instead. For example, CONCAT('Hello', ' World') in MySQL vs 'Hello' || ' World' in PostgreSQL.
Click to reveal answer
beginner
Why is it important to use the correct string quoting in SQL queries?
Using the correct quotes prevents syntax errors and SQL injection risks. Single quotes ensure strings are treated as data, while double quotes are for identifiers. Mixing them up can cause errors or security issues.
Click to reveal answer
Which quotes should you use to write a string literal in SQL?
ANo quotes
BDouble quotes (" ")
CBackticks (` `)
DSingle quotes (' ')
How do you concatenate strings in standard SQL?
AUsing + operator
BUsing || operator
CUsing CONCAT() function only
DUsing & operator
In MySQL, how do you concatenate 'Hello' and 'World'?
ACONCAT('Hello', 'World')
B'Hello' || 'World'
C'Hello' + 'World'
D'Hello' & 'World'
What does double quotes around a word mean in SQL?
AComment
BString literal
CIdentifier like column or table name
DNumber
What is a risk of using wrong quotes in SQL queries?
AAll of the above
BSQL injection
CSyntax errors
DWrong data retrieval
Explain the difference between single and double quotes in SQL and why it matters.
Think about how SQL treats data vs names.
You got /4 concepts.
    Describe how string concatenation differs between standard SQL, MySQL, and PostgreSQL.
    Focus on operators and functions used.
    You got /4 concepts.