Sale sign in the product list | Вывеска распродаж в списке товаров

Help me make it
There is a sale sign in the table with the list of products, I need it to appear only when the discount percentage is indicated for this product in the sale field. I can’t figure out how to do this for each entry in the table

Помогите мне сделать это
В таблице со списком товаров есть знак распродажи, мне нужно, чтобы он появлялся только тогда, когда в поле распродажи указан процент скидки на этот товар. Я не могу понять, как это сделать для каждой записи в таблице

Без имени
test.pma (316.6 KB)

You can use SQL CASE statement:

SELECT *, 
CASE 
   WHEN discount <> '' THEN 'dd848dd100e613c5a15bd8e81f3242b3.png'
   ELSE ''
END discount_image
FROM data LIMIT 0, -1

Where dd848dd100e613c5a15bd8e81f3242b3.png is Image widget filename.

Check this example table_image.pma (216.5 KB)

1 Like

Great, thanks a lot!
Супер, большое спасибо!

Is it possible to create in the condition “image_name”+discount_number+".png"
Возможно ли создать в условие “имя_изображения”+номер_скидки+".png"

WHEN discount <> '' THEN 'discount_'+discount+'.png'

Try this:

WHEN discount <> '' THEN 'discount_' || discount || '.png'

Looking for SQLite CONCAT? Use The Concatenation Operator || Instead (sqlitetutorial.net)

1 Like

Back to Flipabit >
Copyright © 2018. Flipabit Team. All rights reserved.