INSERT INTO target_table (field1, field2)
SELECT field1, field2 FROM temporary_table WHERE not EXISTS(
select 1 from target_table where temporary_table.id = target_table.id
)
SELECT SUBSTRING_INDEX(field_name, ' ', 10) FROM table_name WHERE condition
json_decode($json, true)
вместо(array) json_decode($json)
, подробнее в документации.<?php
$dir = '/path/to/dir';
function countFilesInDir($pathToDir, array $exludes = []){
$filesCount = 0;
$directoryIterator = new DirectoryIterator($pathToDir);
foreach ($directoryIterator as $file){
if ($file->isDot()) continue;
/**
* @var SPLFileInfo $file
*/
if (in_array($file->getBasename(), $exludes)) continue;
if ($file->isFile()){
$filesCount++;
}
}
return $filesCount;
}
echo countFilesInDir($dir, ['index.php']);
SELECT a.*,
album_photos.file,
album_photos.date,
(select COUNT(id) from photos where album_id = a.id) as photo_count
FROM
`albums` as a
left join photos as album_photos on a.id = album_photos.album_id
and album_photos.`date` = ( select max(`date`) from `photos` where album_id = a.id)
WHERE
a.`user_id` = 1
ORDER BY
a.`date` DESC
LIMIT 10
WHERE
(t3.name = 'black' and t5.name = 'S')
and
(t3.name = 'black' and t5.name = 'M')
and
(t5.name = 'L')
WITH cteName as (
SELECT SCHED.mList_id, ml.id, MD.mList_id, SM.mList_id
FROM [TEST].[dbo].[PATP_Schedule] AS SCHED
INNER JOIN TEST..PATP_MarshrutList AS ML
ON SCHED.mList_id = ML.id
INNER JOIN TEST..PATP_MarshrutData AS MD
ON MD.mList_id = ML.id
INNER JOIN [TEST].[dbo].[PATP_SubMarshrut] AS SM
ON ML.id = SM.mList_id
)
UPDATE cteName set mList_id = <someValue>;