select *
from FruitsTABLE f
where name = 'яблоко'
and exists (select *
from FruitTagTABLE t
where t.fruit = f.fruit
and f.tag = 'сладкий'
)
and exists (select *
from FruitTagTABLE t
where t.fruit = f.fruit
and f.tag = 'круглый'
)
and exists (select *
from oc_product_attribute a
where a.product_id=p2a.product_id
and a.attribute_id = 12
and a.text LIKE '%ЛПО%'
)
SELECT
OBJECT_NAME(i.object_id) AS [Table Name]
, i.name AS [Index Name]
, i.is_disabled
, s.last_user_update AS [Last Update Time]
, s.user_updates AS [Updates]
, user_scans
, user_seeks
, user_lookups
, last_user_scan
, last_user_seek
, last_user_lookup
FROM sys.dm_db_index_usage_stats AS s
JOIN sys.indexes AS i ON i.object_id = s.object_id AND i.index_id = s.index_id
JOIN sys.objects AS o ON o.object_id = s.object_id
WHERE s.database_id = DB_ID()
AND OBJECTPROPERTY(i.[object_id], 'IsSystemTable' ) = 0
AND INDEXPROPERTY (i.[object_id], i.name, 'IsAutoStatistics') = 0
AND INDEXPROPERTY (i.[object_id], i.name, 'IsHypothetical' ) = 0
AND INDEXPROPERTY (i.[object_id], i.name, 'IsStatistics' ) = 0
AND INDEXPROPERTY (i.[object_id], i.name, 'IsFulltextKey' ) = 0
AND o.type <> 'IT'
AND i.object_id = object_id('TABLE_NAME')
ORDER BY OBJECT_NAME(i.object_id)
update Table1
set F1 = (SELECT TOP 1 (F2) FROM Table2 T2 WHERE T1.F3 = T2.F4 order by Id desc)
from Table1 t1
update Table1
set F1 = (SELECT MAX(F2) FROM Table2 T2 WHERE T1.F3 = T2.F4 GROUP BY F2)
from Table1 t1
select *
from table t1
where `id attrbute` = 1
and Значение = "Ель"
and exists (select * from table t2
where t1.`id product` = t2.`id product`
and t2.`id attrbute` = 2 and t2.Значение = 200)
and exists (select * from table t3
where t1.`id product` = t3.`id product`
and t3.`id attrbute` = 3 and t3.Значение = 10)