dimanche 3 juillet 2016

MySql - Create a table and select from it in the same procedure


I’m trying to execute this simple code as a procedure in MySql using the PHPMyAdmin

CREATE TEMPORARY TABLE IF NOT EXISTS jobs AS (SELECT
    *
FROM
    all_jobs
WHERE
        job_object_type LIKE 'jobName'
        OR
        job_object_type LIKE 'jobStatus');

SELECT
    *
FROM
    jobs

But I’m getting an error (#1064) because of my second SELECT query. I’m coming from MS-SQL and there the SELECT would be executed without any problems. How can I execute the CREATE TABLE X query and direct after that the SELECT * FROM X query in the same procedure?

EDIT: forgot to mention that I’m using the MariaDB


Aucun commentaire:

Enregistrer un commentaire