"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
https://fgheysels.github.io/
1
2
3
4
5
6
7
8
9
10
11
12
| SELECT child.id, parent.id, CONCAT(IF (STRCMP(NULL,parent.omschrijving), '', parent.omschrijving), child.omschrijving) AS omschrijving FROM ezpagecategorie child LEFT JOIN ezpagecategorie parent ON child.id_ezpagecategorie = parent.id ORDER BY omschrijving |
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
Ik lees hierin:Op maandag 08 juli 2002 13:03 schreef Skef het volgende:
code:
1 2SELECT CONCAT(IF (STRCMP('',parent.omschrijving), '', parent.omschrijving), child.omschrijving) AS omschrijving
[...]
concateneer parent.omschrijving en child.omschrijving
waarom doe je dat ook niet gewoon ipv die STRCMP en IF - constructie?
En als ik dat concat, dan krijg ik weer hetzelfde liedje: weer die NULL.....
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'
CONCAT_WS(separator, str1, str2,...)
CONCAT_WS() stands for CONCAT With Separator and is a special form of CONCAT(). The first argument is the separator for the rest of the arguments. The separator can be a string as well as the rest of the arguments. If the separator is NULL, the result will be NULL. The function will skip any NULLs and empty strings, after the separator argument. The separator will be added between the strings to be concatenated:
mysql> SELECT CONCAT_WS(",","First name","Second name","Last Name");
-> 'First name,Second name,Last Name'
mysql> SELECT CONCAT_WS(",","First name",NULL,"Last Name");
-> 'First name,Last Name'
Gevonden op www.mysql.com/doc en dan kijken bij de string-functions
Net iets later dan Janoz
FF wat anders: Kun je in mysql een recursive query maken?
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
Ken dit?
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
Op maandag 08 juli 2002 13:20 schreef Skef het volgende:
Ik heb dus iid iets van een boomstructuur, en nu wil ik (als dit mogelijk is) zonder tussenkomst van PHP die boomstructuur laten returnen in een veld dmv een concat oid...
Ken dit?
Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'
Hell noOp maandag 08 juli 2002 13:23 schreef Janoz het volgende:
Zeer waarschijnlijk niet. Er zijn wel andere methoden om een boomstructur te achterhalen met slechts 1 query, maar dit legt wel beperkingen aan bijvoorbeeld de diepte en het aantal kinderen op.
Hmm, is alleen het resultaat niet in 1 veld... Ff iets te snel gelezen, maar misschien heb je er toch wat aan
Nu is mijn tree zoiets:
1
2
3
4
5
6
7
8
| _Kennisplein | |_moederschap | | | |_geestelijk | |_fysiek | |_vaderschap |
Veel dieper dan 3 a 4 niveau's gaat het niet...
Iemand een idee?
Edit: en het gaat er dus om, dat ik puur dingen zoals "Kennisplein - moederschap - geestelijk" uit die concat krijg...
En onder elk tree-element zijn ook weer pagina's te knallen...
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
Dit kan niet, omdat het binnen een cms komt, waar een heleboel standaard-componenten in zitten (open-module, save-module enz.)...Op maandag 08 juli 2002 14:28 schreef elviver het volgende:
Waarom kan je PHP er nix meer aan doen erna?
Deze query wordt uiteindelijk opgeslagen in de database, en wordt gebruikt om op het moment dat iemand iets wil openen uit die tabel, de inhoud van de tabel op de juiste wijze weer te geven. Dit doet ie in een heleboel gevallen automatisch (hij pakt dan alleen de eerste string welke in een tabel voorkomt), maar een aantal gevallen vereist een speciale query, met wat uitgebreidere informatie.
Zie eerdere topics (zoek maar eens op concat, of Skef binnen /14, en je komt zat tegen wat daar ook in draait)...
Snap je 't nog?
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
Heb je ook ff bij de efficientie gekeken daar? Niet echt gunstigOp maandag 08 juli 2002 14:16 schreef elviver het volgende:
[..]
Hell noCheck deze draad maar es
edit:
Hmm, is alleen het resultaat niet in 1 veld... Ff iets te snel gelezen, maar misschien heb je er toch wat aan
Ken Thompson's famous line from V6 UNIX is equaly applicable to this post:
'You are not expected to understand this'
Hoe kan ik een niveautje of 4/5 diep gaan in een query, waarbij de concat de waarden aan elkaar zet en returned als "omschrijving"?
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| SELECT
first.id,
CONCAT_WS(' - ',sixth.omschrijving, fifth.omschrijving, fourth.omschrijving, third.omschrijving, second.omschrijving, first.omschrijving) AS omschrijving
FROM
ezpagecategorie first
LEFT JOIN
ezpagecategorie second
ON
first.id_ezpagecategorie = second.id
LEFT JOIN
ezpagecategorie third
ON
second.id_ezpagecategorie = third.id
LEFT JOIN
ezpagecategorie fourth
ON
third.id_ezpagecategorie = fourth.id
LEFT JOIN
ezpagecategorie fifth
ON
fourth.id_ezpagecategorie = fifth.id
LEFT JOIN
ezpagecategorie sixth
ON
fifth.id_ezpagecategorie = sixth.id
ORDER BY
omschrijving |
(sorry voor de layout-fucked-up)
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
Op maandag 08 juli 2002 14:16 schreef elviver het volgende:
[..]
Hell noCheck deze draad maar es
edit:
Hmm, is alleen het resultaat niet in 1 veld... Ff iets te snel gelezen, maar misschien heb je er toch wat aan
"Computer games don’t affect kids: I mean if Pac-Man affected us as kids, we’d all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."