With as clause for my sql

Hi there,

I’m using MySql and WITH temp_name AS clause to create temporary tables is not working.

That’s what I did:

WITH groups AS
(SELECT…),
answer AS
(SELECT…
SELECT *
FROM groups
CROSS JOIN answer;

Could someone let me know if WITH… AS works for MySQL and also how to replace that if it doesn’t work?

Thanks in advance! Dri

Hi @dribarbosa, welcome to the forums!

It looks like MySQL CTEs (common table expressions using the WITHAS syntax) should function much the same as in SQLite. If your current query is not working, it may be due to a typo or missing comma/semicolon rather than the WITHAS statement. Here is the documentation from MySQL:

2 Likes