0

Beginner with MariaDB and trying to understand the syntax. I’m trying to create the simplest example and then build from there. Shouldn’t the following work?

with myCTE as 
  (SELECT 1 as MyNum, 'A' as MyChar  
  UNION  
  SELECT 2 as MyNum, 'B' as MyChar)  
SELECT *  
FROM myCTE  

I’m looking at the following three references and believe that I am adhering to their approach:

  1. https://www.mariadbtutorial.com/mariadb-basics/mariadb-cte/
  2. https://www.mysqltutorial.org/mysql-cte/
  3. https://mariadb.com/kb/en/non-recursive-common-table-expressions-overview/

I’m sure I’m missing something simple, but just can’t see it.
Using MariaDB and TablePlus on iPad and I get generic error message:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'myCTE as ( … Thanks for the assistance… First question on Stackoverflow

W2000
  • 1
  • Shouldn't it be tagged with `sql` too? – AnilGoyal Jul 31 '21 at 02:02
  • 1
    CTEs are available in Mariadb 10.2 . You may consider using subqueries or upgrading to continue with your query as is – ggordon Jul 31 '21 at 02:11
  • Thanks ‘ggordon’ I just saw that when I went back to read. Just started with Mariadb in docker on rpi..I’ll look into upgrading. – W2000 Jul 31 '21 at 02:19
  • Thanks AnilGoyal… I will catch that next time. – W2000 Jul 31 '21 at 02:19
  • 1
    Reference for Mariadb upgrade for anyone finding this in the future. https://stackoverflow.com/questions/68308764/how-to-upgrade-mariadb-running-as-a-docker-container – W2000 Jul 31 '21 at 02:23
  • Please don't submit questions about eoled MariaDB database versions. Upgrade to a more recent version and then check again and reconsider to ask. – Georg Richter Sep 18 '21 at 19:25

0 Answers0