A
A
Albert Kazan2019-07-28 15:02:12
MySQL
Albert Kazan, 2019-07-28 15:02:12

How to write IF THEN ELSE?

Hello
I don't know how to write such conditions in the request. For the first time it has to.
I found and tried various methods from the Internet, but they all give nothing but errors.
It's hard to even describe what I want. Something like:

IF (SELECT COUNT(*) FROM replies WHERE id=1 AND flag=1) = 1) THEN
UPDATE replies SET flag=0 WHERE id=1
ELSE
INSERT INTO replies (id,flag) VALUES(1,0)
END

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rsa97, 2019-07-28
@Rsa97

Why such perversion?

INSERT INTO `replies` (`id`, `flag`)
  VALUES (:id, 0)
  ON DUPLICATE KEY UPDATE `flag` = 0;

P
Petya Persianov, 2017-11-18
@Dr0nk

htmlbook.ru/css/overflow-x
overflow-x: hidden;

A
Artemy, 2017-11-18
Kaydash @kayart

I do not recommend using overflow-x: hidden in this particular case. The best solution would be to use the word-wrap property: break-word - wrapping a long word to a new line. This way your content won't spill out of the block even in extreme cases. Using overflow-x will tritely cut off the part of the word that goes beyond the block, which in practice will give a negative result.
A prime example is using the word Tetrahydropyranylcyclopentyltetrahydropyridine, cutting which will make the content lose its meaning.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question