Re: [PHP] Getting two queries into one result set

2005-02-02 Thread Shaun
Hi guys,

Thanks for your replies but neither UNION or REGEXP can be used with SHOW 
TABLES...

Any ideas?

Jochem Maas [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Marek Kilimajer wrote:
 Shaun wrote:

 Hi,

 I have a query where I select all table names where the table name has 
 PID_1 in i.e.

 SHOW TABLES LIKE '%PID_1%';

 However there may be cases where I need to search for tables where the 
 table name is PID_1 or PID_2. In MySQL this can't be done in one query, 
 so how can I do two queries and combine the result set so I can loop 
 through it?

 Thanks for your help


 SHOW TABLES REGEXP 'PID_[0-9]+';


 nice! :-) 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Getting two queries into one result set

2005-02-02 Thread Jay Blanchard
[snip]
Thanks for your replies but neither UNION or REGEXP can be used with
SHOW 
TABLES...
[/snip]

SHOW TABLES is such a limited query and allows for such primitive
conditionals that you would probably have better results doing two
queries and looping them into the same output

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting two queries into one result set

2005-02-02 Thread Marek Kilimajer
Shaun wrote:
Hi guys,
Thanks for your replies but neither UNION or REGEXP can be used with SHOW 
TABLES...

Any ideas?
It's time to change your table design. Use one pid table and add another 
column that would hold the number.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Getting two queries into one result set

2005-02-02 Thread Graham Cossey
You don't say how many tables you have, how they are named or anything
outside of the query itself.

Assuming that not all your tables are named PID_* how about simply doing

SHOW TABLES LIKE '%PID_%'

and selecting appropriate results within the php script using strstr
or regular expressions? SHOW TABLES is (normally) such a quick query
returning a larger result set shouldn't be too much of a problem,
should it?

HTH

Graham

On Wed, 02 Feb 2005 15:15:38 +0100, Marek Kilimajer [EMAIL PROTECTED] wrote:
 Shaun wrote:
  Hi guys,
 
  Thanks for your replies but neither UNION or REGEXP can be used with SHOW
  TABLES...
 
  Any ideas?
 
 It's time to change your table design. Use one pid table and add another
 column that would hold the number.
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


-- 
Graham

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting two queries into one result set

2005-02-02 Thread Tom
Graham Cossey wrote:
You don't say how many tables you have, how they are named or anything
outside of the query itself.
Assuming that not all your tables are named PID_* how about simply doing
SHOW TABLES LIKE '%PID_%'
and selecting appropriate results within the php script using strstr
or regular expressions? SHOW TABLES is (normally) such a quick query
returning a larger result set shouldn't be too much of a problem,
should it?
 

If it is, then you should rework your db to reduce the number of tables :)
Alternatively use multi-query with use_result and more_results.
If it's concise code that you are after, then set up all the search 
strings in an array, and pass this through a loop that performs each 
query at a time and cats the results into a new array.

HTH
Graham
On Wed, 02 Feb 2005 15:15:38 +0100, Marek Kilimajer [EMAIL PROTECTED] wrote:
 

Shaun wrote:
   

Hi guys,
Thanks for your replies but neither UNION or REGEXP can be used with SHOW
TABLES...
Any ideas?
 

It's time to change your table design. Use one pid table and add another
column that would hold the number.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   


 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Getting two queries into one result set

2005-01-26 Thread Shaun
Hi,

I have a query where I select all table names where the table name has PID_1 
in i.e.

SHOW TABLES LIKE '%PID_1%';

However there may be cases where I need to search for tables where the table 
name is PID_1 or PID_2. In MySQL this can't be done in one query, so how can 
I do two queries and combine the result set so I can loop through it?

Thanks for your help 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Getting two queries into one result set

2005-01-26 Thread Marek Kilimajer
Shaun wrote:
Hi,
I have a query where I select all table names where the table name has PID_1 
in i.e.

SHOW TABLES LIKE '%PID_1%';
However there may be cases where I need to search for tables where the table 
name is PID_1 or PID_2. In MySQL this can't be done in one query, so how can 
I do two queries and combine the result set so I can loop through it?

Thanks for your help 

SHOW TABLES REGEXP 'PID_[0-9]+';
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Getting two queries into one result set

2005-01-26 Thread Jochem Maas
Marek Kilimajer wrote:
Shaun wrote:
Hi,
I have a query where I select all table names where the table name has 
PID_1 in i.e.

SHOW TABLES LIKE '%PID_1%';
However there may be cases where I need to search for tables where the 
table name is PID_1 or PID_2. In MySQL this can't be done in one 
query, so how can I do two queries and combine the result set so I can 
loop through it?

Thanks for your help

SHOW TABLES REGEXP 'PID_[0-9]+';
nice! :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php