SELECT COUNT(*)
FROM product_options AS PO
JOIN product_options AS P1 ON P0.product_id = P1.product_id
JOIN product_options AS P2 ON P0.product_id = P2.product_id
WHERE
(PO.classifier_id = 1 AND PO.option_id IN (5))
AND
(P1.classifier_id = 3 AND P1.option_id IN (29))
AND
(P2.classifier_id = 4 AND P2.option_id IN (55, 57, 59))
CREATE TABLE tbl( date DATETIME, name VARCHAR(25), price INT);
INSERT INTO tbl VALUES
('2020-01-01', 'laptop', 210),
('2020-01-01', 'pc', 100),
('2020-01-02', 'laptop', 150),
('2020-01-02', 'pc', 200),
('2020-01-03', 'laptop', 150),
('2021-01-01', 'pc', 110),
('2021-01-01', 'laptop', 220),
('2021-01-02', 'pc', 210),
('2021-01-02', 'laptop', 200),
('2021-01-03', 'pc', 260);
SELECT T2.date, T2.name, ( T2.price + T1.price ) / 2
FROM tbl T2
JOIN tbl T1 ON T1.name = T2.name
AND T1.date = LAST_DAY(T2.date - INTERVAL 1 MONTH) + INTERVAL 1 DAY
ORDER BY 1, 2
он ищет отдельными словами
CONCAT_WS( ' ', ' ', name1, name2, name3, ' ' ) LIKE '% Иван %'
AND
CONCAT_WS( ' ', ' ', name1, name2, name3, ' ' ) LIKE '% Иванович %'
AND
CONCAT_WS( ' ', ' ', name1, name2, name3, ' ' ) LIKE '% Иванов %'
Like the error says, row is a tuple, so you can't do row["pool_number"]. You need to use the index: row[0].
result = await cur.execute("SELECT balance FROM profile WHERE uid=%s", user.id)
row = await cur.fetchall()
if result == 1:
return row[0]