select e.id, e.name
from employee e
join (
select employee_id
from empl_services es
join services s on s.id = es.service_id
where s.title in ('Крутит гайки','Носит ящики')
group by employee_id
having count(1) = 2
) t on t.employee_id = e.id
;
-- если id услуг известны то так:
select e.id, e.name
from employee e
join (
select employee_id
from empl_services es
where service_id in (1,3)
group by employee_id
having count(1) = 2
) t on t.employee_id = e.id
;
with
s as (
select id from services where title in ('Крутит гайки','Носит ящики')
),
r as (
select employee_id from empl_services es
join s on s.id = es.service_id
group by employee_id
having count(employee_id) = (select count(1) from s)
)
select *
from employee e
join r on r.employee_id = e.id
;
while($row = mysqli_fetch_array($res))
$res = mysqli_query($dbc, $query);
SELECT * FROM `pupils` WHERE class = 'НОМЕРКЛАССА' -- я допустил что колонка у вас называется class
SELECT DISTINCT class FROM `pupils` -- я допустил что колонка у вас называется class
<div class="cl">
<h3>НОМЕРКЛАССА</h3>
SELECT * FROM `pupils` WHERE class = 'НОМЕРКЛАССА' -- я допустил что колонка у вас называется class
<h4>ФИО</h4>
</div>
7-Zip 19.00 (x86) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Usage: 7z [...] [...] [@listfile]
a : Add files to archive
b : Benchmark
d : Delete files from archive
e : Extract files from archive (without using directory names)
h : Calculate hash values for files
i : Show information about supported formats
l : List contents of archive
rn : Rename files in archive
t : Test integrity of archive
u : Update files to archive
x : eXtract files with full paths
-- : Stop switches and @listfile parsing
-ai[r[-|0]]{@listfile|!wildcard} : Include archives
-ax[r[-|0]]{@listfile|!wildcard} : eXclude archives
-ao{a|s|t|u} : set Overwrite mode
-an : disable archive_name field
-bb[0-3] : set output log level
-bd : disable progress indicator
-bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
-bt : show execution time statistics
-i[r[-|0]]{@listfile|!wildcard} : Include filenames
-m{Parameters} : set compression Method
-mmt[N] : set number of CPU threads
-mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)
-o{Directory} : set Output directory
-p{Password} : set Password
-r[-|0] : Recurse subdirectories
-sa{a|e|s} : set Archive name mode
-scc{UTF-8|WIN|DOS} : set charset for for console input/output
-scs{UTF-8|UTF-16LE|UTF-16BE|WIN|DOS|{id}} : set charset for list files
-scrc[CRC32|CRC64|SHA1|SHA256|*] : set hash function for x, e, h commands
-sdel : delete files after compression
-seml[.] : send archive by email
-sfx[{name}] : Create SFX archive
-si[{name}] : read data from stdin
-slp : set Large Pages mode
-slt : show technical information for l (List) command
-snh : store hard links as links
-snl : store symbolic links as links
-sni : store NT security information
-sns[-] : store NTFS alternate streams
-so : write data to stdout
-spd : disable wildcard matching for file names
-spe : eliminate duplication of root folder for extract command
-spf : use fully qualified file paths
-ssc[-] : set sensitive case mode
-sse : stop archive creating, if it can't open some input file
-ssw : compress shared files
-stl : set archive timestamp from the most recently modified file
-stm{HexMask} : set CPU thread affinity mask (hexadecimal number)
-stx{Type} : exclude archive type
-t{Type} : Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName] : Update options
-v{Size}[b|k|m|g] : Create volumes
-w[{path}] : assign Work directory. Empty path means a temporary directory
-x[r[-|0]]{@listfile|!wildcard} : eXclude filenames
-y : assume Yes on all queries
"C:\Program Files (x86)\7-Zip\7z.exe" x -so G:\FIAS\fias_07.10.19.zip sql_file1.sql | G:\MySqlWork\mysql.exe -uroot -p 4830 newBase
"C:\Program Files (x86)\7-Zip\7z.exe" x -so G:\FIAS\fias_07.10.19.zip sql_file2.sql | G:\MySqlWork\mysql.exe -uroot -p 4830 newBase
Строчку 'valueDstidArr',r(CONCAT(`value_src`.id),`value_dst`.value) - concat заменить на group_concat не получается пишет что синтаксическая ошибка.
GROUP_CONCAT(DISTINCT JSON_OBJECT(
'value', `value_dst`.value,
'param_dst_id', `value_dst`.param_dst_id,
'type',param_type_id(`value_dst`.param_dst_id),
'ref_id',ref_id(`value_dst`.param_dst_id),
'title',param_title(`value_dst`.param_dst_id),
'valueDstidArr',r(CONCAT(`value_src`.id),`value_dst`.value)
)) AS `realValuesArr2`
...
JSON_OBJECT(
'value', `value_dst`.value,
'param_dst_id', `value_dst`.param_dst_id,
'type',param_type_id(`value_dst`.param_dst_id),
'ref_id',ref_id(`value_dst`.param_dst_id),
'title',param_title(`value_dst`.param_dst_id),
'valueDstidArr', GROUP_CONCAT( r(`value_src`.id,`value_dst`.value) )
) AS `realValuesArr2`
...
SELECT
CONCAT(
'{"',`session`,'":{',
GROUP_CONCAT('"PRODUCT ', @i:=@i+1, '":{"PRODUCT ID":',product_id,',"PRICE":',price,',"QUANTITY":',quantity,'}' separator ','),
'}}') AS value
FROM carts, (SELECT @i:=0) X
WHERE `session` = 222145
GROUP BY `session`
$session_id = 222145;
$sql = 'SELECT
CONCAT(
\'{"\',`session`,\'":{\',
GROUP_CONCAT(\'"PRODUCT \', @i:=@i+1, \'":{"PRODUCT ID":\',product_id,\',"PRICE":\',price,\',"QUANTITY":\',quantity,\'}\' separator \',\'),
\'}}\') AS value
FROM carts, (SELECT @i:=0) X
WHERE `session` = %s
GROUP BY `session`';
$arr = json_decode(mysql_result(mysql_query(sprintf($sql, $session_id)),0), true);
var_dump( $arr );
INSERT INTO tmp_goods (name, article, price)
VALUES ('NAME_1', 'ARTICLE_1', PRICE 1),
.......
('NAME_N', 'ARTICLE_N', PRICE_N)
;
UPDATE goods g
INNER JOIN tmp_goods t ON t.article = g.article
SET g.price = t.price
WHERE g.price != t.price
;
UPDATE goods
SET price = CASE article
WHEN ARTICLE_1 THEN PRICE_1
WHEN ARTICLE_2 THEN PRICE_2
....
ELSE price END
UPDATE goods g
INNER JOIN (
SELECT 'ARTICLE-1' AS article, PRICE_1 AS price UNION
SELECT 'ARTICLE-2', PRICE_2 UNION
SELECT 'ARTICLE-3', PRICE_3 UNION
...
SELECT 'ARTICLE-N', PRICE_N
) t ON t.article = g.article
SET g.price = t.price
WHERE g.price != t.price
;
SELECT m.*, u.* FROM messages m
INNER JOIN users u ON m.receiver = u.id
INNER JOIN (
SELECT receiver, sender, max(date) as date
FROM messages
GROUP BY receiver, sender
) m2 ON m.receiver = m2.receiver
AND m.sender = m2.sender
AND m.date = m2.date
WHERE u.id = 1
ORDER BY m.date DESC
SELECT m.*, u.* FROM messages m
INNER JOIN users u ON m.sender = u.id
INNER JOIN (
SELECT receiver, sender, max(date) as date
FROM messages
GROUP BY receiver, sender
) m2 ON m.receiver = m2.receiver
AND m.sender = m2.sender
AND m.date = m2.date
WHERE m.receiver = 1
ORDER BY m.date DESC
select c.title, count(p.product_id )
from (
select title, category_id from categories c where c.category_id IN (1,2)
UNION
select
(select title from categories c1 where c1.category_id = c.parent_id) as title,
category_id
from categories c where parent_id IN (1,2)
) c
JOIN products p ON p.category_id = c.category_id
GROUP BY c.title
SELECT
Proect,
CodZadachi,
Tema,
Status,
Ispolnitel,
Avtor,
CONCAT(
CASE DATE_FORMAT(DataSozdania,'%m')
WHEN '01' THEN 'Январь'
WHEN '02' THEN 'Февраль'
WHEN '03' THEN 'Март'
WHEN '04' THEN 'Апрель'
WHEN '05' THEN 'Май'
WHEN '06' THEN 'Июнь'
WHEN '07' THEN 'Июль'
WHEN '08' THEN 'Август'
WHEN '09' THEN 'Сентябрь'
WHEN '10' THEN 'Октябрь'
WHEN '11' THEN 'Ноябрь'
WHEN '12' THEN 'Декабрь'
END,
DATE_FORMAT(DataSozdania,' %e %H:%i %Y')
) AS DataSozdania,
Opisanie,
DataSoveschania,
SrokIspolnenia,
FROM БД WHERE OTKRITA = 1 AND Proect = 'ТАБЛИЦА'
UPDATE score sc
SET score = score + (
SELECT card * 3.75 + cardrack * 7.5 + videocardroom * 15
FROM auto1 a
WHERE a.vk_id = sc.vk_id
)
;
IF((`mf`.`ID` IS NOT NULL AND `a`.`Price` > 0), 1, 0) DESC