PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > mysql.general > Auto Fill blank Rows
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Auto Fill blank Rows

Réponse
 
LinkBack Outils de la discussion
Vieux 12/03/2008, 17h50   #1
roger.maynard
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Auto Fill blank Rows

Anyone got any bright ideas of how to solve this one?

I have documents which can contain up to 15 rows of information.
Each row as it is added to the document reference can have any ROW_ID
from 1 to 15 when it is added.

I want to be able to "Auto Fill" the blank rows on a SELECT.

eg

data in table is

ROW_ID | Reference
===================================
1 | Reference Line 1
3 | Reference Line 3
9 | Reference Line 9
11 | Reference Line 11
15 | Reference Line 15

RESULT REQUIRED is

ROW_ID | Reference
===================================
1 | Reference Line 1
2 |
3 | Reference Line 3
4 |
5 |
6 |
7 |
8 |
9 | Reference Line 9
10 |
11 | Reference Line 11
12 |
13 |
14 |
15 | Reference Line 15

I've been playing about with joins on a "dummy" table containing just
rows 1 to 15, but am stuck in my thinking at the moment.

Any gratefully received

Roger

  Réponse avec citation
Vieux 12/03/2008, 18h05   #2
Phil
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Auto Fill blank Rows

you could do something like

select dummy.row_id,real.reference from dummy left join real on
real.row_id=dummy.row_id;

would give NULL on the 'missing' rows,

On Wed, Mar 12, 2008 at 12:50 PM, roger.maynard <
roger.maynard@crayford.ltd.uk> wrote:

> Anyone got any bright ideas of how to solve this one?
>
> I have documents which can contain up to 15 rows of information.
> Each row as it is added to the document reference can have any ROW_ID
> from 1 to 15 when it is added.
>
> I want to be able to "Auto Fill" the blank rows on a SELECT.
>
> eg
>
> data in table is
>
> ROW_ID | Reference
> ===================================
> 1 | Reference Line 1
> 3 | Reference Line 3
> 9 | Reference Line 9
> 11 | Reference Line 11
> 15 | Reference Line 15
>
> RESULT REQUIRED is
>
> ROW_ID | Reference
> ===================================
> 1 | Reference Line 1
> 2 |
> 3 | Reference Line 3
> 4 |
> 5 |
> 6 |
> 7 |
> 8 |
> 9 | Reference Line 9
> 10 |
> 11 | Reference Line 11
> 12 |
> 13 |
> 14 |
> 15 | Reference Line 15
>
> I've been playing about with joins on a "dummy" table containing just
> rows 1 to 15, but am stuck in my thinking at the moment.
>
> Any gratefully received
>
> Roger
>




--
build our city at http://free-dc.myminicity.com !

  Réponse avec citation
Vieux 12/03/2008, 18h23   #3
Bill Newton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Auto Fill blank Rows

To get a blank line instead of NULL you could simply wrap the reference
in an IFNULL function:

select dummy.row_id,IFNULL(real.reference,'') as Reference from dummy left join real on
real.row_id=dummy.row_id;





Phil wrote:
> you could do something like
>
> select dummy.row_id,real.reference from dummy left join real on
> real.row_id=dummy.row_id;
>
> would give NULL on the 'missing' rows,
>
> On Wed, Mar 12, 2008 at 12:50 PM, roger.maynard <
> roger.maynard@crayford.ltd.uk> wrote:
>
>
>> Anyone got any bright ideas of how to solve this one?
>>
>> I have documents which can contain up to 15 rows of information.
>> Each row as it is added to the document reference can have any ROW_ID
>> from 1 to 15 when it is added.
>>
>> I want to be able to "Auto Fill" the blank rows on a SELECT.
>>
>> eg
>>
>> data in table is
>>
>> ROW_ID | Reference
>> ===================================
>> 1 | Reference Line 1
>> 3 | Reference Line 3
>> 9 | Reference Line 9
>> 11 | Reference Line 11
>> 15 | Reference Line 15
>>
>> RESULT REQUIRED is
>>
>> ROW_ID | Reference
>> ===================================
>> 1 | Reference Line 1
>> 2 |
>> 3 | Reference Line 3
>> 4 |
>> 5 |
>> 6 |
>> 7 |
>> 8 |
>> 9 | Reference Line 9
>> 10 |
>> 11 | Reference Line 11
>> 12 |
>> 13 |
>> 14 |
>> 15 | Reference Line 15
>>
>> I've been playing about with joins on a "dummy" table containing just
>> rows 1 to 15, but am stuck in my thinking at the moment.
>>
>> Any gratefully received
>>
>> Roger
>>
>>

>
>
>
>



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h02.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10794 seconds with 11 queries