BigInteger b;
do{
b = new BigInteger(48, new SecureRandom());
} while (b.toString().length()!=14);
System.out.println(b.toString());
select distinct vegetables.name
from vegetables, deliveries, routes, pathes
where
deliveries.vegetable = vegetables.id and
routes.id=deliveries.route and
pathes.route=deliveries.route and
exists (
select * from pathes, points
where pathes.route=route.id and
from pathes.fromPoint=points.id and points.Name='Москва') and
exists (
select * from pathes, points
where pathes.route=route.id and
from pathes.toPoint=points.id and points.Name='Тюмень')
select * from table where instr ( concat(';',addr,';'),';Москва;') > 0
select * from table where instr ( concat(';',lang,';'),';рус;') > 0
select * from table where instr ( concat(';',times,';'),';пт;') > 0
WITH
RECURSIVE search_graph(id, ref_id) AS
(
SELECT id, ref_id
FROM Users
UNION ALL
SELECT o.id, o.ref_id
FROM Users o
JOIN search_graph p ON p.ref_id = o.id
)
SELECT array_agg(id || ' -> ' ) AS "path"
FROM search_graph
GROUP BY id
ORDER BY id
;
select t2.* from table1 t1,table1 t2
where
t1.from_user_id=t2.to_user_id and
t2.from_user_id=t1.to_user_id and
t1.from_user_id=5
select BSproduct from
( -- Список продуктов имеющих черный цвет и малый размер
select product as BSProduct from
(
SELECT t1.id, t1.name AS product, t3.name AS color, t5.name AS size
FROM `product` AS t1
JOIN `product_color` AS t2 ON t1.id = t2.product_id
JOIN `color` AS t3 ON t2.color_id = t3.id
JOIN `product_size` AS t4 ON t1.id = t4.product_id
JOIN `size` AS t5 ON t4.size_id = t5.id
)
where color = "black" and size = "S"
) as BlackAndSmallSize,
( -- Список продуктов имеющих черный цвет и средний размер
select product as BMProduct from
(
SELECT t1.id, t1.name AS product, t3.name AS color, t5.name AS size
FROM `product` AS t1
JOIN `product_color` AS t2 ON t1.id = t2.product_id
JOIN `color` AS t3 ON t2.color_id = t3.id
JOIN `product_size` AS t4 ON t1.id = t4.product_id
JOIN `size` AS t5 ON t4.size_id = t5.id
)
where color = "black" and size = "M"
) as BlackAndMidSize,
( -- Список продуктов имеющих большой размер
select product as LProduct from
(
SELECT t1.id, t1.name AS product, t3.name AS color, t5.name AS size
FROM `product` AS t1
JOIN `product_color` AS t2 ON t1.id = t2.product_id
JOIN `color` AS t3 ON t2.color_id = t3.id
JOIN `product_size` AS t4 ON t1.id = t4.product_id
JOIN `size` AS t5 ON t4.size_id = t5.id
)
where size = "L"
) as LargeSize
where BSProduct=BMProduct and BMProduct=LProduct
(
SELECT t1.id, t1.name AS product, t3.name AS color, t5.name AS size
FROM `product` AS t1
JOIN `product_color` AS t2 ON t1.id = t2.product_id
JOIN `color` AS t3 ON t2.color_id = t3.id
JOIN `product_size` AS t4 ON t1.id = t4.product_id
JOIN `size` AS t5 ON t4.size_id = t5.id
)