SELECT * FROM `shops` WHERE LOWER(`name`) REGEXP 'ноутбук'
$params = [1, 3, 4, 6];
$clause = implode(',', array_fill(0, count($params), '?'));
$types = str_repeat('i', count($params));
$stmt = $mysqli->prepare("SELECT * FROM comments WHERE id IN ($clause)");
$stmt->bind_param($types, ...$params);
$stmt->execute();
$resArr = $stmt->get_result()->fetch_all(MYSQLI_ASSOC);
if(!$resArr) exit('No rows');
var_export($resArr);
$stmt->close();
$sum = 0;
while ($result = mysqli_fetch_array($query)){
echo $result['balance'].'<br>';
$sum += $result['balance'];
}
echo $sum / 5;
You can use the alias in GROUP BY, ORDER BY, or HAVING clauses.https://dev.mysql.com/doc/refman/8.0/en/problems-w...
Standard SQL disallows references to column aliases in a WHERE clause. This restriction is imposed because when the WHERE clause is evaluated, the column value may not yet have been determined.
SELECT `id`, `name`, SUBSTR(`text`, 1,20) AS `text` FROM `articles` ORDER BY `id` DESC
SELECT *, SUBSTR(`text`, 1,20) AS `shorttext` FROM `articles` ORDER BY `id` DESC
SELECT
*
FROM
tableName
WHERE
fieldName IN (
SELECT
fieldName
FROM
tableName
GROUP BY
fieldName
HAVING COUNT(fieldName) > 1
);