SELECT `p`.`thread_id`
FROM `msg_participants` AS `p`
JOIN `msg_participants` AS `t` USING(`thread_id`)
WHERE `p`.`user_id` = ?
AND `t`.`user_id` = ?
SELECT `p`.`thread_id`
FROM (SELECT `thread_id` FROM `msg_participants` WHERE `user_id` = ?)
AS `p`
JOIN (SELECT `thread_id` FROM `msg_participants` WHERE `user_id` = ?)
AS `t` USING(`thread_id`)
SELECT `t`.`id`, `au`.`login`, `pu`.`login`, `t`.`task_message`, `ts`.`status`
FROM `TASK` AS `t`
LEFT JOIN `USER` AS `au` ON `au`.`id` = `t`.`author_user_id`
LEFT JOIN `USER` AS `pu` ON `pu`.`id` = `t`.`performer_user_id`
LEFT JOIN `TASK_STATUS AS `ts` ON `ts`.`id` = `t`.`status`
WHERE ...
SELECT `w`.`gym`, `t`.`name`, `c`.`name`, `w`.`sttime`, `w`.`entime`
FROM `workout` AS `w`
LEFT JOIN `trainers` AS `t` ON `t`.`id` = `w`.`trainer`
LEFT JOIN `clients` AS `c` ON `c`.`id` = `w`.`client`
WHERE `w`.`date` = CURDATE()
ORDER BY `w`.`sttime`
myQuery->SQL->Text = (AnsiString)"SELECT f_department.CODE, f_department.NAME FROM f_department LEFT JOIN l_modules_22_department ON l_modules_22_department.CODE_2 = f_department.CODE WHERE l_modules_22_department.CODE_1 = '"
+ depBlock[i].moduleCode + (AnsiString)"'";
SELECT `id`, `date`, `name`
FROM `table`
ORDER by `date`, `id`
LIMIT 10
SELECT `id`, `name`, `date`
FROM `table`
WHERE (@Date := (SELECT `date` FROM `table` WHERE `id` = :last_id))
AND (`date` > @Date OR (`date` = @Date AND `id` > :last_id))
ORDER BY `date`, `id`
LIMIT 10
SELECT sum(`Acheck`.`TOTAL`) AS `SUME`,
strftime('%Y - %m', `Acheck`.`LOGICDATE`) AS `LOGICDATE`
FROM `Categ`
JOIN `Menu` ON `Categ`.`SIRF` = `Menu`.`Categ`
JOIN `ARcheck` ON `Menu`.`SIRF` = `ARcheck`.`SIFR`
JOIN `Acheck` ON `ARcheck`.`SYS_NUM` = `Acheck`.`SYS_NUM`
WHERE `Categ`.`SIRF` = 2
GROUP BY `LOGICDATE`
SELECT sum(`Acheck`.`TOTAL`) AS `SUME`,
strftime('%Y - %m', `Acheck`.`LOGICDATE`) AS `LOGICDATE`
FROM `Acheck`
JOIN `ARcheck` ON `ARcheck`.`SYS_NUM` = `Acheck`.`SYS_NUM`
JOIN `Menu` ON `Menu`.`SIRF` = `ARcheck`.`SIFR`
JOIN `Categ` ON `Categ`.`SIRF` = `Menu`.`Categ`
WHERE `Categ`.`SIRF` = 2
GROUP BY `LOGICDATE`
ALTER TABLE `comments`
ADD COLUMN `peoples_id` INT(255) NOT NULL AFTER `comment`,
ADD INDEX `peoples_id_idx` (`peoples_id` ASC);
ALTER TABLE `comments`
ADD CONSTRAINT `comments_peoples`
FOREIGN KEY (`peoples_id_fk`)
REFERENCES `peoples` (`id_people`)
ON DELETE NO ACTION
ON UPDATE NO ACTION;
UNION (SELECT 0 as Orders, 0 as Hours)
UNION (SELECT 0 as Orders, 1 as Hours)
...
UNION (SELECT 0 as Orders, 23 as Hours)
Не знаю, как именно это будет записываться в MSSQL $sql = "UPDATE indexing_link SET title='".$title."', short='".$short ."' WHERE id=".$id_current_url;
print $sql;
mysqli_query($mysqli, $sql) or die('Error_ ('.mysqli_errno($mysqli).') '.mysqli_error($mysqli));
SELECT DISTINCT `res`.`id_page` FROM `fields_value` AS `res`
INNER JOIN `fields_value` AS `f1` ON (`f1`.`id_page` = `res`.`id_page` AND `f1`.`id_field` = 22 AND `f1`.`value` = 'Платный')
INNER JOIN `fields_value` AS `f2` ON (`f2`.`id_page` = `res`.`id_page` AND `f2`.`id_field` = 11 AND `f2`.`value` = '100')
INNER JOIN `fields_value` AS `f3` ON (`f3`.`id_page` = `res`.`id_page` AND `f3`.`id_field` = 33 AND `f3`.`value` = 'есть')
SELECT `employer`.*
FROM `EmployesInfo` AS `employer`
RIGHT JOIN `EmployesInfo` AS `chief` ON `employer`.`ChiefId` = `chief`.`emplId`
RIGHT JOIN (SELECT `ChiefId`, COUNT(`ChiefId`) AS `count`
FROM `EmployesInfo`
GROUP BY `ChiefId`
HAVING `count` >= 3) AS `sub` ON `employer`.`ChiefId` = `sub`.`ChiefId`
WHERE `chief`.`EmplCar` IS NOT NULL