

(E.g., MAX (country_id ), LIMIT 1, etc…). Of course, we can always re-write the query in a myriad number of ways to return just one row. The specific error, query returned more than one row is returned because STRICT requires that no more than one row be returned from the query results that are the target of a variable of SELECT INTO.Īs seen previously, without STRICT we get no run-time errors and variable ‘c_id’ is set with the first row from the unordered result set. Suppose I have this query that returns all columns for any cities that start with ‘Z’:ĬONTEXT: PL/pgSQL function get_country ( ) line 4 at SQL statement MySQL SELECT INTO Syntax Part 3 – DUMPFILE with examplesįor the example queries in this post, I’ll use a couple of tables from the PostgreSQL practice DVD Rental database.MySQL SELECT INTO Syntax Part 2 – Saving to OUTFILE with examples.MySQL SELECT INTO Syntax Part 1 – Uses With Variables.
#Select into in postgresql free#
Feel free to visit them each in turn below.

Since coffee is my favorite drink, you can even buy me one if you would like!Īlthough I targeted a different SQL dialect, I wrote 3 fantastic blog posts exploring SELECT INTO I’d love for you to read. If you enjoy the content written here, by all means, share this blog and your favorite post(s) with others who may benefit from or like it as well.

