Tvoj prvi SELECT v Kotomarketu
What you'll learn
- napisati in zagnati svojo prvo poizvedbo v obliki
SELECT * FROM products LIMIT 5 - nadzorovati velikost rezultata s spreminjanjem števila vrstic v
LIMIT - razložiti, zakaj je
SELECTvaren: podatke samo bere in v bazi ničesar ne spremeni
Najpomembnejša poizvedba
QUERY pred teboj razpre konzolo arhiva — jantarno okno v temi oddelka. Za njim molči baza Kotomarketa: kupci, izdelki, naročila in vedenjski dogodki, zamrznjeni v letu 2024. Namig s konca izvoza je bil jasen: začni s SELECT.
Večina dela s SQL se res začne s preprostim dejanjem: prebrati podatke. Temu je namenjen ukaz SELECT — vprašanje, na katero baza odgovori s podatki: »pokaži mi, kaj imaš«.
Začnimo z izložbo in pokukajmo v tabelo products. Spodnja poizvedba pravi: »vrni vse stolpce (*) iz tabele products, vendar največ 5 vrstic«. Tu je LIMIT n omejitev: bazi naroči, naj vrne največ n vrstic (malo pozneje — v 2. poglavju — ga bomo podrobno obdelali skupaj z razvrščanjem). Pritisni Zaženi — in prve vrstice izložbe, ki so spale 160 let, oživijo na holopanelu. Nato spremeni 5 v 10 in takoj boš videl, kako nadzoruješ obseg rezultata.
QUERY: Kar pritisni.
SELECTsamo bere — s poizvedbo za branje arhiva ne moreš pokvariti. Sem preveril. Večkrat.

SELECT zbudi izložbo: pet vrstic products se iz teme dvigne na holopanel.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 |