Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)
edited by

It appears that MySQL doesn't have array variables. What should I use instead?

There seem to be like two alternatives suggested: A set-type scalar and temporary tables. But is it a good way to use these instead of the array variables? Alternatively, if I am going with sets, what would be the set-based idiom equivalent to foreach?

1 Answer

0 votes
by (12.7k points)

Well, I had been using the temporary tables instead of array variables. It is not the most excellent solution, but it works.

Note that you do not need to formally define their fields, just create them using a SELECT:

DROP TEMPORARY TABLE IF EXISTS my_temp_table;
CREATE TEMPORARY TABLE my_temp_table
    SELECT first_name FROM people WHERE last_name = 'Smith';

If you want to learn more about SQL, Check out this SQL Certification by Intellipaat.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...