I have a pretty long sqlite query:
const char *sql_query = "SELECT statuses.word_id FROM lang1_words, statuses WHERE statuses.word_id = lang1_words.word_id ORDER BY lang1_words.word ASC";
How can I break it in a number of lines to make it easier to read?
If I do the following:
const char *sql_query = "SELECT word_id
FROM table1, table2
WHERE table2.word_id = table1.word_id
ORDER BY table1.word ASC";
I am getting an error.
Is there a way to write queries in multiple lines?
There are two ways to split strings over multiple lines:
Each string on its own line. Works only with strings:
Plain C:
Objective-C:
Using
\– can be used for any expression:Plain C:
Objective-C:
The first approach is better, because there isn’t a lot of whitespace included. For a SQL query however, both are possible.
NOTE: With a
#define, you have to add an extra\to concatenate the two strings:Plain C: