Reputation: 4808
I was reading another stackoverflow question and puzzled here...
$query=" SELECT account.id, client.client_id\n"
. " FROM account, client\n"
. " WHERE account.id = 19";
Are those newline escapes ok in the query?
My question is:
Is statement like "selection * from student where \n \n \n id='10'"
error free?
Upvotes: 1
Views: 2954
Reputation: 554
The newlines in your above example will have no effect on the query or result set for that matter.
It really has nothing to do with MySQL actually, but rather with PHP. When you quote a string in double quotes and use \n or \r escape chars, PHP simply interprets them into special characters, namely a newline or carriage return. php.net/manual/en/language.types.string.php Therefore the above query is basically a query over 3 lines which MySQL accepts perfectly as something like:
SELECT account.id, client.client_id
FROM account, client
WHERE account.id = 19
Think of a script file where the query is over several lines of the file. Similar thing
Upvotes: 2