La tua prima query SELECT su Kotomarket
What you'll learn
- a scrivere ed eseguire la tua prima query nella forma
SELECT * FROM products LIMIT 5 - a controllare quante righe ottieni modificando il numero in
LIMIT - a spiegare perché
SELECTè sicuro: legge soltanto i dati e non modifica nulla nel database
La query più importante di tutte
QUERY apre davanti a te la console dell'archivio: una finestra color ambra nel buio del compartimento. Al di là dello schermo, il database di Kotomarket resta in silenzio: clienti, prodotti, ordini e interazioni, fermi al 2024. Il suggerimento in fondo al era chiaro: comincia da SELECT.
La maggior parte del lavoro in SQL parte da un gesto semplice: leggere i dati. A questo serve il comando SELECT: fai una domanda e il database risponde con i dati, in pratica «mostrami che cosa hai».
Partiamo dalla vetrina e diamo un'occhiata alla tabella products. La query qui sotto chiede: «restituisci tutte le colonne (*) della tabella products, ma non più di 5 righe». Qui LIMIT n fa da limite: dice al database di restituire al massimo n righe (per ora lo anticipiamo soltanto: lo vedremo in dettaglio, insieme all'ordinamento, nel Capitolo 2). Premi Esegui: le prime righe della vetrina, addormentate da 160 anni, si riaccenderanno sull'olopannello. Poi cambia 5 in 10: vedrai subito come controllare la quantità di risultati.
QUERY: Premi senza timore.
SELECTlegge soltanto: con una query di lettura non puoi rovinare l'archivio. Ho verificato. Più volte.

SELECT risveglia la vetrina: cinque righe di products emergono dal buio sull'olopannello.The single most important query
QUERY unfolds the archive console in front of you — an amber window in the darkness of the bay. Behind it the "Kotomarket" database sits in silence: buyers, products, orders and behavioral events, frozen since 2024. The hint at the end of the was clear: start with SELECT.
Most work with SQL really does begin with one simple act: read the data. That’s what the SELECT command is for — a question the database answers with data: "show me what you’ve got."
Let’s start with the storefront and peek into the products table. The query below asks: "return every column (*) from the products table, but no more than 5 rows." Here LIMIT n is the limiter: it tells the database to return at most n rows (looking ahead — we’ll dig into it properly, together with sorting, in Chapter 2). Hit Run, and the first rows of the storefront, asleep for 160 years, will come alive on the holopanel. Then change 5 to 10 — and you’ll see right away how to control how much the result returns.
QUERY: Go ahead, hit it.
SELECTonly reads — you can’t spoil the archive with a read query. I’ve tested that. Many times over.
| id | name | category | price | stock |
|---|---|---|---|---|
| 1 | Беспроводные наушники | Электроника | 5990.00 | 120 |
| 2 | Смарт-часы | Электроника | 8990.00 | 60 |
| 3 | Портативная колонка | Электроника | 3490.00 | 90 |
| 4 | Веб-камера HD | Электроника | 2790.00 | 45 |
| 5 | Механическая клавиатура | Электроника | 4590.00 | 70 |