PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > subquery, alias and derived tables
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
subquery, alias and derived tables

Réponse
 
LinkBack Outils de la discussion
Vieux 03/10/2007, 13h18   #1
hans christian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut subquery, alias and derived tables


Hello, I am trying to come up with a way to preform the same query over a
list of tables; of which the tablenames are stored in a ... table.

I have tried numerous ways but unfortunatly the column name is not
expanded or treated as the tablename in the outerquery. So I am trying
now with a subquery only to get caught in the alias mixer. For example:

mysql> SELECT open,high,low,close FROM (SELECT tablename FROM properties);
ERROR 1248 (42000): Every derived table must have its own alias

Is there a way to receive the list of tablenames and preform a subquery
within the same select statement ?

If so I am going to keep searching for the answer using subquery
otherwise I will have to come up with something else.

Thank you for any suggestions.

Cheers,

Hans.
  Réponse avec citation
Vieux 03/10/2007, 13h58   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery, alias and derived tables

On 3 Oct, 13:18, hans christian <christ...@notmail.com> wrote:
> Hello, I am trying to come up with a way to preform the same query over a
> list of tables; of which the tablenames are stored in a ... table.
>
> I have tried numerous ways but unfortunatly the column name is not
> expanded or treated as the tablename in the outerquery. So I am trying
> now with a subquery only to get caught in the alias mixer. For example:
>
> mysql> SELECT open,high,low,close FROM (SELECT tablename FROM properties);
> ERROR 1248 (42000): Every derived table must have its own alias
>
> Is there a way to receive the list of tablenames and preform a subquery
> within the same select statement ?
>
> If so I am going to keep searching for the answer using subquery
> otherwise I will have to come up with something else.
>
> Thank you for any suggestions.
>
> Cheers,
>
> Hans.


I think you need a stored procedure

  Réponse avec citation
Vieux 03/10/2007, 21h50   #3
hans christian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery, alias and derived tables

On Wed, 03 Oct 2007 05:58:20 -0700, Captain Paralytic wrote:

> On 3 Oct, 13:18, hans christian <christ...@notmail.com> wrote:
>> Hello, I am trying to come up with a way to preform the same query over
>> a list of tables; of which the tablenames are stored in a ... table.
>>
>> I have tried numerous ways but unfortunatly the column name is not
>> expanded or treated as the tablename in the outerquery. So I am trying
>> now with a subquery only to get caught in the alias mixer. For example:
>>
>> mysql> SELECT open,high,low,close FROM (SELECT tablename FROM
>> properties); ERROR 1248 (42000): Every derived table must have its own
>> alias
>>
>> Is there a way to receive the list of tablenames and preform a subquery
>> within the same select statement ?
>>
>> If so I am going to keep searching for the answer using subquery
>> otherwise I will have to come up with something else.
>>
>> Thank you for any suggestions.
>>
>> Cheers,
>>
>> Hans.

>
> I think you need a stored procedure


Hmmm 2 bad

Anyway thank you for your answer !

Hans.
  Réponse avec citation
Vieux 04/10/2007, 12h44   #4
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery, alias and derived tables

On 3 Oct, 21:50, hans christian <christ...@notmail.com> wrote:
> On Wed, 03 Oct 2007 05:58:20 -0700, Captain Paralytic wrote:
> > On 3 Oct, 13:18, hans christian <christ...@notmail.com> wrote:
> >> Hello, I am trying to come up with a way to preform the same query over
> >> a list of tables; of which the tablenames are stored in a ... table.

>
> >> I have tried numerous ways but unfortunatly the column name is not
> >> expanded or treated as the tablename in the outerquery. So I am trying
> >> now with a subquery only to get caught in the alias mixer. For example:

>
> >> mysql> SELECT open,high,low,close FROM (SELECT tablename FROM
> >> properties); ERROR 1248 (42000): Every derived table must have its own
> >> alias

>
> >> Is there a way to receive the list of tablenames and preform a subquery
> >> within the same select statement ?

>
> >> If so I am going to keep searching for the answer using subquery
> >> otherwise I will have to come up with something else.

>
> >> Thank you for any suggestions.

>
> >> Cheers,

>
> >> Hans.

>
> > I think you need a stored procedure

>
> Hmmm 2 bad
>
> Anyway thank you for your answer !
>
> Hans.- Hide quoted text -
>
> - Show quoted text -


Why 2bad?

  Réponse avec citation
Vieux 05/10/2007, 15h34   #5
hans christian
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery, alias and derived tables

On Thu, 04 Oct 2007 04:44:52 -0700, Captain Paralytic wrote:

> On 3 Oct, 21:50, hans christian <christ...@notmail.com> wrote:
>> On Wed, 03 Oct 2007 05:58:20 -0700, Captain Paralytic wrote:
>> > On 3 Oct, 13:18, hans christian <christ...@notmail.com> wrote:
>> >> Hello, I am trying to come up with a way to preform the same query
>> >> over a list of tables; of which the tablenames are stored in a ...
>> >> table.

>>
>> >> I have tried numerous ways but unfortunatly the column name is not
>> >> expanded or treated as the tablename in the outerquery. So I am
>> >> trying now with a subquery only to get caught in the alias mixer.
>> >> For example:

>>
>> >> mysql> SELECT open,high,low,close FROM (SELECT tablename FROM
>> >> properties); ERROR 1248 (42000): Every derived table must have its
>> >> own alias

>>
>> >> Is there a way to receive the list of tablenames and preform a
>> >> subquery within the same select statement ?

>>
>> >> If so I am going to keep searching for the answer using subquery
>> >> otherwise I will have to come up with something else.

>>
>> >> Thank you for any suggestions.

>>
>> >> Cheers,

>>
>> >> Hans.

>>
>> > I think you need a stored procedure

>>
>> Hmmm 2 bad
>>
>> Anyway thank you for your answer !
>>
>> Hans.- Hide quoted text -
>>
>> - Show quoted text -

>
> Why 2bad?


Because I'm lazy ...

Hans.
  Réponse avec citation
Vieux 10/10/2007, 10h52   #6
jcwebb@dicoe.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery, alias and derived tables

Hello,
i have the same problem.
Did you find then answer, please?
J

  Réponse avec citation
Vieux 12/10/2007, 10h55   #7
bamroberts@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: subquery, alias and derived tables

On Oct 3, 1:18 pm, hans christian <christ...@notmail.com> wrote:
> Hello, I am trying to come up with a way to preform the same query over a
> list of tables; of which the tablenames are stored in a ... table.
>
> I have tried numerous ways but unfortunatly the column name is not
> expanded or treated as the tablename in the outerquery. So I am trying
> now with a subquery only to get caught in the alias mixer. For example:
>
> mysql> SELECT open,high,low,close FROM (SELECT tablename FROM properties);
> ERROR 1248 (42000): Every derived table must have its own alias
>
> Is there a way to receive the list of tablenames and preform a subquery
> within the same select statement ?
>
> If so I am going to keep searching for the answer using subquery
> otherwise I will have to come up with something else.
>
> Thank you for any suggestions.
>
> Cheers,
>
> Hans.


Hi Hans

Try this: "SELECT open,high,low,close FROM (SELECT tablename FROM
properties) as my_table; "

  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 05h32.


Édité par : vBulletin® version 3.7.2
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
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12698 seconds with 15 queries