kerncy's solution to "SQL - Search cell delimited by carriage_return"

this should do the work :<\/p>\n

SELECT<\/span> <\/span>*<\/span> <\/span>FROM<\/span> <\/span>table<\/span> <\/span>WHERE<\/span> <\/span>emailalias<\/span> <\/span>LIKE<\/span>  <\/span>&<\/span>quot<\/span>;<\/span>%\\<\/span>n$_GET<\/span>[<\/span>&<\/span>quot<\/span>;<\/span>email&quot<\/span>;]<\/span>\\<\/span>n<\/span>%&<\/span>quot<\/span>;<\/span> <\/span>or<\/span> <\/span>emailalias<\/span> <\/span>like<\/span> <\/span>&<\/span>quot<\/span>;<\/span>$<\/span>_GET<\/span>[<\/span>&<\/span>quot<\/span>;<\/span>email&quot<\/span>;]<\/span>\\<\/span>n<\/span>%&<\/span>quot<\/span>;<\/span> <\/span>or<\/span> <\/span>emailalias<\/span> <\/span>LIKE<\/span> <\/span>&<\/span>quot<\/span>;<\/span>%\\<\/span>n$_GET<\/span>[<\/span>&<\/span>quot<\/span>;<\/span>email&quot<\/span>;]<\/span>&<\/span>quot<\/span>;<\/span>\n<\/pre><\/div>\n

Test carriage return with \\n and test also first and last line which are not surrounded by \\n.<\/p>\n

this should do the work : SELECT * FROM table WHERE emailalias LIKE "%\n$_GET["email"]\n%" or emailalias like "$_GET["email"]\n%" or emailalias LIKE "%\n$_GET["email"]" Test carriage return with \n and test also first and last line which are not surrounded by \n. Updated solution as in comment : SELECT * FROM table WHERE CONCAT('=', REPLACE(REPLACE(emailalias, CHAR(10), '='), CHAR(13), '='), '=') LIKE "%=alf@gmail.com=%" I tested this one in phpmyadmin, it works with your test case.

User: kerncy

Question: SQL - Search cell delimited by carriage_return

Back to question