CREATE TABLE users (
id int primary key auto_increment,
name varchar(64)
);
CREATE TABLE favorites (
user_id int references users(id),
bookmark varchar(255),
primary key (user_id, bookmark)
);
select user_id
from tbl
where entity_id in (24, 25)
group by user_id
having count(distinct entity_id) = 2;
<?php
$query = "SELECT COUNT(*) cnt FROM sakila.actor;";
// get DB version using PDO
$stmt = $pdo->prepare($query);
$stmt->execute();
$count = $stmt->fetchColumn();
printf("Count rows in table actor is: %d", $count);
select json_arrayagg(
json_object(
'id', id,
'headlineEn', headlineEn,
'posttextEn', posttextEn
)
)
from posts;
SELECT p.*, category_titles, filter_titles
FROM products as p
LEFT JOIN (
SELECT product_id, json_arrayagg(c.title) category_titles from product_category as pc
JOIN categories as c ON pc.category_id=c.id
GROUP BY product_id
) pc ON p.id=pc.product_id
JOIN (
SELECT product_id, json_arrayagg(f.title) filter_titles
FROM product_filter as pf
JOIN filters as f ON pf.filter_id=f.id
GROUP BY product_id
) pf ON p.id=pf.product_id
WHERE p.id='2'
UPDATE `notice`
SET `time_update` = ?, `current_value` = ?
WHERE `id` = ? AND `time_update` = `time`;
но я же хочу через RedBean подключение к БДИ кто Вам мешает. Почитайте документацию RedBean в части взаимодействия с базой данных
SELECT id, (c1=1) + (c2=0) + (c3=1) + (c4=1) + (c5=1) + (c6=1) + (c7=1) FROM test
WHERE ((c1=1) + (c2=0) + (c3=1) + (c4=1) + (c5=1) + (c6=1) + (c7=1)) >= 6
;
<?php
$mysqli->query("SET NAMES 'utf8'");
$mysqli->query("CREATE TABLE `geolocal` (
`id` INT AUTO_INCREMENT,
`names` VARCHAR(50),
`pass` VARCHAR(20),
`email` VARCHAR (50),
PRIMARY KEY(`id`)
)"
);
$mysqli->query(
"INSERT INTO `geolocal` (`names`, `pass`, `email`) VALUES ('spiderman', 'pautinka', 's.pider@list.ru')"
);
$mysqli->close();