Categories
MySQL sql

SQL count(): The Most Popular Cake

This post contiues the SQL tutorial on the Shire Bakery. Here we’ll So how do yo find the most popular cake in the Shire Bakery? Here’s an idea. — Show the best cookie — See: Ben Forta Chap. 16 SELECT COUNT( cakes.cake ) AS ‘popular’, cakes.cake, costumers.who FROM cakes, costumers, likes — sort out the […]

Categories
Multimedia Design MySQL

SQL: Many-to-Many and One-to-Many

Here’s a short tutorial on how to solve some basic SQL cardinalities. First have a look at the ER-diagram for the database and the resulting tables in PhpMyAdmin. Many-to-Many Many to many cardinalities may be solved like this: SELECT cake, who FROM cakes, costumers, likes WHERE costumers.costumers_id = likes.costumers_id AND cakes.cakes_id = likes.cakes_id Note that […]

Categories
WAU Blog

At vende grafen i læseretningen

Det blev lidt kringlet, da grafen: Skulle vise de seneste 30 resultater Skulle kunne læses fra venstre mod højre I PHP MyAdmin fandt jeg ud af, at SQL-sætningen kunne se omtrent således ud: $sql = $wpdb->get_results( “SELECT * FROM `tablename` WHERE name=’$username’ ORDER BY adate DESC” ); $sql er sorteret sådan, at grafen ville vende […]

Categories
WAU Blog

Udfordring: pagination

Programmeringsmæssigt bliver en af udfordringerne at håndtere “pagination”, dvs. sideopdeling af astmadagbogen. Efterhånden som der kommer flere og flere poster i astmabloggens tabel, så bliver det en nødvendighed. Pt. har jeg ikke fundet et oplagt eksempel. Måske skal man bare tænke det lidt enkelt. En tæller “i” = længden af arrayet. Så trækker man “limit” […]

We use cookies - is it ok with you+ more information

Multimusen.dk will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies.

Close