Mistři v programování na #hovnokod

A tohle je v pohledu, kam se posílají další dotazy, takže se to provádí furt dokola. A Adminer to vyplivnul všechno na 1 řádku.

SELECT
	product.product_id, product.producer_id, product.style_id, product.dodavatel_id, product.old_navi, product_info.short_info, product_info.long_info,
	product_info.language_id, product_info.product_name, product_info.seo_title, product_info.seo_keywords, product_info.seo_description,
	minprices."row", minprices.product_spec_id, minprices.sleva, minprices.interni_id
FROM
	(
		(
			(product JOIN product_info USING (product_id))
			JOIN (
				SELECT store_central.product_id
				FROM store_central
				WHERE (store_central.units >= (-1000))

				UNION SELECT sety_skupiny.product_id
				FROM sety_skupiny
				WHERE (sety_skupiny.typ = 3)
			) used_product USING (product_id)
		)
		JOIN (
			SELECT
				product_spec.product_id, product_spec."row", min(product_spec.product_spec_id) AS product_spec_id,
				min(product_spec.interni_id) AS interni_id, min(product_spec.sleva) AS sleva
			FROM (
				product_spec JOIN (
					SELECT
						product_spec.product_id, min(product_spec."row") AS "row"
					FROM
						product_spec
					WHERE
						(
							(
								(product_spec."row" <> (0)::numeric)
								AND (
									product_spec.product_spec_id IN (
										SELECT store_central.product_spec_id
										FROM store_central
										WHERE (store_central.units >= (-1000))
									)
								)
							)
							OR
							(
								product_spec.product_id IN (
									SELECT sety_skupiny.product_id
									FROM sety_skupiny
									WHERE (sety_skupiny.typ = 3)
								)
							)
						)
					GROUP BY
						product_spec.product_id
				) minp USING (product_id, "row")
			)
			GROUP BY
				product_spec.product_id, product_spec."row"
		) minprices USING (product_id)
	)
	WHERE (
		(product_info.product_name <> ''::text)
		AND (
			NOT (
				product.product_id IN (
					SELECT product_notshow_2.product_id
					FROM product_notshow_2
				)
			)
		)
	);

Anonymous,

když nevěříš, že proběhl update

CREATE PROCEDURE [dbo].[MyProc]
(
	@ID int = NULL,
	@myDate datetime = NULL
)
AS
	UPDATE myTable
		SET	myDate = @dmyDate
	WHERE id = @ID
		
	DECLARE @newMyDate datetime = null
 
	SELECT @newMyDate = myDate FROM myTable WHERE id = @ID

	IF @myDate = @newMyDate
	BEGIN
		SELECT 1 
	END
	ELSE
	BEGIN
		SELECT 0
	END

Anonymous,


Anonymous,

CREATE TABLE IF NOT EXISTS `ticket_counter` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_slovak_ci AUTO_INCREMENT=162 ;

--
-- Dumping data for table `ticket_counter`
--

INSERT INTO `ticket_counter` (`id`) VALUES
(1),
(2),
(3),
(4),
(5),
...
(158),
(159),
(160),
(161);

Anonymous,

...
left join (select a.a1 || ' ' || a.a2 as a1_2, a.id1 || '@' || a.id2 as b.id from a) as b on b.id = c.b_id
...

Anonymous,