Abel Huanacchiri
Abel Huanacchiri

Reputation: 23

How to use With and Values in Mysql

I have a question, how can I use 'with clause' with params in mysql as I used to do in postgre sql, i.e. using with and values, like below example :

Postgresql:

with params(idmodelo) as (values(10))
select * from modelo where idmodelo  = (select idmodelo from params)

Upvotes: 1

Views: 99

Answers (1)

Bill Karwin
Bill Karwin

Reputation: 562931

The VALUES statement is implemented in MySQL 8.0.19 and later. If you use an earlier version, you must upgrade.

mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.32    |
+-----------+

mysql> with params(idmodelo) as (values row(10)) 
       select * from params;
+----------+
| idmodelo |
+----------+
|       10 |
+----------+

For more details, read the manual entry on the VALUES statement

Upvotes: 2

Related Questions