MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:mfatene Date:June 14 2005 9:09pm
Subject:Re: How to write subqueries?
View as plain text  
You're welcome.

if you have more than one pnid, you should use perl or php. then use a loop to
manage each pnid query, then send it to the server, and use it's result.

another simpler solution :

mysql> create table sql as select concat('vt_',pnid) tbl from vt_parition where
pnid regexp ('^[0-9]{11}$') ;
Query OK, 2 rows affected (0.06 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> select * from sql;
+----------------+
| tbl            |
+----------------+
| vt_01234567890 |
| vt_09876543210 |
+----------------+
2 rows in set (0.00 sec)

mysql> alter table sql modify tbl varchar(255);
Query OK, 2 rows affected (0.14 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> update sql set tbl=concat('select num, theme, intro  from ',tbl,';');
Query OK, 2 rows affected (0.03 sec)
Rows matched: 2  Changed: 2  Warnings: 0

mysql>
mysql> select * from sql;
+------------------------------------------------+
| tbl                                            |
+------------------------------------------------+
| select num, theme, intro  from vt_01234567890; |
| select num, theme, intro  from vt_09876543210; |
+------------------------------------------------+
2 rows in set (0.00 sec)


NOW :
  1. copy/paste and execute
  2. select * into outfile and source
  3. every other extarction/execution method.


Mathias

Selon admin <bvbn@stripped>:

> Hello!
>
> Many thanks to everybody who tried to help me!
>
> > N.B. you should have only one pnid to make your query work (UNIQUE pnid),
> > or LIMIT the result of the subquery by LIMIT 1.
>
> I need to do the following:
>
> Get one or more than one "pnid" from vt_partition and then make queries to
> the
> "vt_pnid" tables. The result (from all the requested "vt_pnid" tables) should
> be sorted by date and time. How to do it?
> The version of MySQL should be 4.1.11 or lower. It would be great if the
> query
> works even on v. 3.23.58.
>
> > First off, you are not writing a subquery. You are attempting to build a
> > SQL query using the results of another query. What you are attempting is
> > dynamic SQL. I am not familiar with a mechanism in 4.1.11 that allow you
> > to execute a string (or a string variable) from within a SQL statement.
>
> > Damn! You're right!! I only looked at the subquery itself, not the context
> > and I missed that šhis "subquery" seems to an expression to get part of his
> > table name! That is definitely not valid in any dialect of SQL that I know
> > ;-)
>
> Agree, I was wrong. :-)
>
> --
> Good luck!
> Vladimir
>
> Please avoid sending me Word or PowerPoint attachments.
> See http://www.gnu.org/philosophy/no-word-attachments.html
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>


Thread
How to write subqueries?Unknown Sender14 Jun
  • Re: How to write subqueries?SGreen14 Jun
    • RE: How to write subqueries?Rhino14 Jun
  • RE: How to write subqueries?Rhino14 Jun
  • Re: How to write subqueries?mfatene14 Jun
    • Re: How to write subqueries?Unknown Sender14 Jun
      • Re: How to write subqueries?mfatene14 Jun
        • Table fullEmmett Bishop15 Jun
          • Re: Table fullmfatene15 Jun
            • Re: Table fullEmmett Bishop15 Jun
              • Re: Table fullmfatene15 Jun
                • Re: Table fullEmmett Bishop15 Jun
                  • Re: Table fullmos16 Jun
                    • Re: Table fullEmmett Bishop16 Jun
                      • Re: Table fullmfatene16 Jun
        • Re: How to write subqueries?Unknown Sender15 Jun
    • Re: How to write subqueries?Unknown Sender14 Jun