←back to thread

Getting AI to write good SQL

(cloud.google.com)
501 points richards | 1 comments | | HN request time: 0.288s | source
1. stefap2 ◴[] No.44010905[source]
I have done this using the OpenAI 4o model. I had to pass in a prompt with business-specific instructions, industry jargon, and descriptions of tables, including foreign keys. Then it would generate even complex join queries and return data. In my case, I was more interested in providing results to users not knowledgeable about SQL, but the SQL was displayed for information.