[{"data":1,"prerenderedAt":401},["ShallowReactive",2],{"docs-\u002Fdocs\u002Fmcp\u002Fexamples\u002Fsql-exploration":3},{"id":4,"title":5,"body":6,"description":392,"extension":393,"meta":394,"navigation":395,"path":396,"redirect":397,"seo":398,"stem":399,"__hash__":400},"docs\u002Fdocs\u002Fmcp\u002Fexamples\u002Fsql-exploration.md","From a plain-English question to ready-to-run SQL",{"type":7,"value":8,"toc":386},"minimark",[9,13,21,51,56,64,67,78,81,170,173,180,195,199,206,329,332,336,361,365,382],[10,11,5],"h1",{"id":12},"from-a-plain-english-question-to-ready-to-run-sql",[14,15,16,20],"p",{},[17,18,19],"strong",{},"Ask a question in plain English — the AI finds the right database, writes the SQL, runs it read-only, and hands you back both the answer and the query."," You don't even need to remember your own schema.",[22,23,24,40],"blockquote",{},[25,26,27,34],"ul",{},[28,29,30,33],"li",{},[17,31,32],{},"Model:"," Claude Haiku 4.5 — the cheapest, fastest Claude.",[28,35,36,39],{},[17,37,38],{},"Sample:"," sakila — the MySQL DVD-rental demo (films, customers, rentals, payments).",[14,41,42,43,46,47,50],{},"Not Opus. Not the top-tier ",[17,44,45],{},"Fable 5"," (the Mythos-class model above Opus). Every join below ran on the ",[17,48,49],{},"budget"," model — that's the point.",[52,53,55],"h2",{"id":54},"round-1-ask-in-plain-english","Round 1 — ask in plain English",[22,57,58],{},[14,59,60,63],{},[17,61,62],{},"You:"," I have a database about movie rentals somewhere in my MySQL connections — I don't remember which one. Find it and show me the top 5 films by total revenue.",[14,65,66],{},"You named nothing — no connection, no database, no table. The AI finds it by chaining read-only tools:",[68,69,75],"pre",{"className":70,"code":72,"language":73,"meta":74},[71],"language-text","list_connections → several MySQL connections\nlist_databases   → spots sakila\nlist_tables      → film, inventory, rental, payment\n","text","",[76,77,72],"code",{"__ignoreMap":74},[14,79,80],{},"Then it writes the four-table join, runs it read-only (30 ms), and answers:",[22,82,83,93],{},[14,84,85,88,89,92],{},[17,86,87],{},"AI:"," Top 5 films by revenue in ",[76,90,91],{},"sakila",":",[94,95,96,113],"table",{},[97,98,99],"thead",{},[100,101,102,106,110],"tr",{},[103,104,105],"th",{},"Film",[103,107,109],{"align":108},"right","Revenue",[103,111,112],{"align":108},"Rentals",[114,115,116,128,139,149,159],"tbody",{},[100,117,118,122,125],{},[119,120,121],"td",{},"TELEGRAPH VOYAGE",[119,123,124],{"align":108},"$231.73",[119,126,127],{"align":108},"27",[100,129,130,133,136],{},[119,131,132],{},"WIFE TURN",[119,134,135],{"align":108},"$223.69",[119,137,138],{"align":108},"31",[100,140,141,144,147],{},[119,142,143],{},"ZORRO ARK",[119,145,146],{"align":108},"$214.69",[119,148,138],{"align":108},[100,150,151,154,157],{},[119,152,153],{},"GOODFELLAS SALUTE",[119,155,156],{"align":108},"$209.69",[119,158,138],{"align":108},[100,160,161,164,167],{},[119,162,163],{},"SATURDAY LAMBS",[119,165,166],{"align":108},"$204.72",[119,168,169],{"align":108},"28",[14,171,172],{},"Another question, different tables, same flow:",[22,174,175],{},[14,176,177,179],{},[17,178,62],{}," And who's my single biggest-spending customer?",[22,181,182],{},[14,183,184,186,187,190,191,194],{},[17,185,87],{}," KARL SEAL — ",[17,188,189],{},"$221.55"," across 45 payments (runner-up: Eleanor Hunt, $216.54). Joined ",[76,192,193],{},"customer → payment",".",[52,196,198],{"id":197},"round-2-keep-the-queries","Round 2 — keep the queries",[22,200,201],{},[14,202,203,205],{},[17,204,62],{}," Give me those queries so I can run them myself in the SQL Console.",[22,207,208,213,282,285],{},[14,209,210,212],{},[17,211,87],{}," Top films by revenue:",[68,214,218],{"className":215,"code":216,"language":217,"meta":74,"style":74},"language-sql shiki shiki-themes github-light github-dark","SELECT f.title,\n       ROUND(SUM(p.amount), 2)      AS revenue,\n       COUNT(DISTINCT r.rental_id)  AS rentals\nFROM film f\nJOIN inventory i ON i.film_id = f.film_id\nJOIN rental    r ON r.inventory_id = i.inventory_id\nJOIN payment   p ON p.rental_id = r.rental_id\nGROUP BY f.film_id, f.title\nORDER BY revenue DESC\nLIMIT 5;\n","sql",[76,219,220,228,234,240,246,252,258,264,270,276],{"__ignoreMap":74},[221,222,225],"span",{"class":223,"line":224},"line",1,[221,226,227],{},"SELECT f.title,\n",[221,229,231],{"class":223,"line":230},2,[221,232,233],{},"       ROUND(SUM(p.amount), 2)      AS revenue,\n",[221,235,237],{"class":223,"line":236},3,[221,238,239],{},"       COUNT(DISTINCT r.rental_id)  AS rentals\n",[221,241,243],{"class":223,"line":242},4,[221,244,245],{},"FROM film f\n",[221,247,249],{"class":223,"line":248},5,[221,250,251],{},"JOIN inventory i ON i.film_id = f.film_id\n",[221,253,255],{"class":223,"line":254},6,[221,256,257],{},"JOIN rental    r ON r.inventory_id = i.inventory_id\n",[221,259,261],{"class":223,"line":260},7,[221,262,263],{},"JOIN payment   p ON p.rental_id = r.rental_id\n",[221,265,267],{"class":223,"line":266},8,[221,268,269],{},"GROUP BY f.film_id, f.title\n",[221,271,273],{"class":223,"line":272},9,[221,274,275],{},"ORDER BY revenue DESC\n",[221,277,279],{"class":223,"line":278},10,[221,280,281],{},"LIMIT 5;\n",[14,283,284],{},"And top customers by spend:",[68,286,288],{"className":215,"code":287,"language":217,"meta":74,"style":74},"SELECT c.first_name, c.last_name,\n       ROUND(SUM(p.amount), 2) AS total_spent,\n       COUNT(*)                AS payments\nFROM customer c\nJOIN payment p ON p.customer_id = c.customer_id\nGROUP BY c.customer_id, c.first_name, c.last_name\nORDER BY total_spent DESC\nLIMIT 5;\n",[76,289,290,295,300,305,310,315,320,325],{"__ignoreMap":74},[221,291,292],{"class":223,"line":224},[221,293,294],{},"SELECT c.first_name, c.last_name,\n",[221,296,297],{"class":223,"line":230},[221,298,299],{},"       ROUND(SUM(p.amount), 2) AS total_spent,\n",[221,301,302],{"class":223,"line":236},[221,303,304],{},"       COUNT(*)                AS payments\n",[221,306,307],{"class":223,"line":242},[221,308,309],{},"FROM customer c\n",[221,311,312],{"class":223,"line":248},[221,313,314],{},"JOIN payment p ON p.customer_id = c.customer_id\n",[221,316,317],{"class":223,"line":254},[221,318,319],{},"GROUP BY c.customer_id, c.first_name, c.last_name\n",[221,321,322],{"class":223,"line":260},[221,323,324],{},"ORDER BY total_spent DESC\n",[221,326,327],{"class":223,"line":266},[221,328,281],{},[14,330,331],{},"Paste either into the SQL Console — they already returned real rows above.",[52,333,335],{"id":334},"what-this-shows","What this shows",[25,337,338,344,355],{},[28,339,340,343],{},[17,341,342],{},"You ask in plain language."," The AI walks connection → database → tables itself — no schema lookup, no recalling table names.",[28,345,346,349,350,354],{},[17,347,348],{},"The number is real."," It runs the query under MCP's read-only guard ",[351,352,353],"em",{},"before"," answering, against your actual data.",[28,356,357,360],{},[17,358,359],{},"You keep the query."," Handed back ready to paste and reuse — the AI never touches your write path.",[52,362,364],{"id":363},"whats-next","What's next",[25,366,367,375],{},[28,368,369,370],{},"See another walkthrough: ",[371,372,374],"a",{"href":373},"\u002Fdocs\u002Fmcp\u002Fexamples\u002Ffederated-validation","Cross-source validation with federated queries",[28,376,377,378],{},"Configure your own AI client: ",[371,379,381],{"href":380},"\u002Fdocs\u002Fmcp\u002Fsetup","MCP setup",[383,384,385],"style",{},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":74,"searchDepth":230,"depth":230,"links":387},[388,389,390,391],{"id":54,"depth":230,"text":55},{"id":197,"depth":230,"text":198},{"id":334,"depth":230,"text":335},{"id":363,"depth":230,"text":364},"A real MCP session — ask in plain English, the AI finds the database, writes the SQL, runs it read-only, and returns the answer plus the query. Uses Claude Haiku 4.5 on the sakila MySQL sample.","md",{},false,"\u002Fdocs\u002Fmcp\u002Fexamples\u002Fsql-exploration",null,{"title":5,"description":392},"docs\u002Fmcp\u002Fexamples\u002Fsql-exploration","RaG1ph8oHygYVHC95lkViX7K7EGsYhDCLWwXONeoE_A",1781271516566]