S
S
safenoob2016-06-17 19:15:18
MySQL
safenoob, 2016-06-17 19:15:18

How to add an IF condition in MySQL?

There is such a sign:
067b758248084d829ba546e3331b7fd4.jpg
I want to make such a request. If date is less than today, then UPDATE quey to value 1000, and then the usual SELECT id, date, etc. otherwise, just SELECT
But no matter how I twist with conditions and subqueries, it doesn’t work out, for example:
SELECT IF(`date` < NOW()) `id`, `query`, `date`

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2016-06-17
@vshvydky

Update.... where query from your if? So not satisfied? And if it doesn’t fit at all, you can use built-in functions and describe anything there.

D
dev400, 2016-06-17
@dev400

As far as I remember IF(Exp, true, false )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question