P
P
Paka2018-10-15 13:12:20
SQL
Paka, 2018-10-15 13:12:20

Why don't user variables work in where?

SELECT
  `num`,
  @tl:=`num`+10
FROM
  (SELECT 1 as `num` UNION SELECT 2) as `t`
WHERE
  @t1 = '11'

Why don't user variables work in where?
At the same time, they don't work in having either...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanovskiy, 2018-10-16
@Sanovskiy

SELECT
  t.num,
  t.num+10 AS tl
FROM
  (SELECT 1 as num UNION SELECT 2 as num) as `t`
having
  tl = '11'

S
shushpanio, 2018-10-16
@shushpanio

Paka Declare your variables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question