SELECT where row value contains string MySQL

Solution 1:

Use the % wildcard, which matches any number of characters.

SELECT * FROM Accounts WHERE Username LIKE '%query%'

Solution 2:

This should work:

SELECT * FROM Accounts WHERE Username LIKE '%$query%'

Solution 3:

My suggestion would be

$value = $_POST["myfield"];

$Query = Database::Prepare("SELECT * FROM TABLE WHERE MYFIELD LIKE ?");
$Query->Execute(array("%".$value."%"));

Solution 4:

SELECT * FROM Accounts WHERE Username LIKE '%$query%'

but it's not suggested. use PDO