Nested queries

2004-02-25 Thread Gregorio






This is the query i want to run but i doesn't work.

select id from c_table where users_id in (select id from users wherelocations_id=3) order by data_ora

But it gives me this error:

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select id from users where locations_id=3) order by data_ora

It seems correct to me. What's the problem?


Gregorio







___ IncrediMail - il mondo della posta elettronica si è finalmente evoluto - Clicca Qui

Re: Nested queries

2004-02-25 Thread Victoria Reznichenko
Gregorio [EMAIL PROTECTED] wrote:
 
 This is the query i want to run but i doesn't work.
 
 select id from c_table where users_id in (select id from users where
 locations_id=3) order by data_ora
 
 But it gives me this error:

 You have an error in your SQL syntax.  Check the manual that corresponds to
 your MySQL server version for the right syntax to use near 'select id from
 users where locations_id=3) order by data_ora
 
 It seems correct to me. What's the problem?
 

Subqueries are supported in MySQL since version 4.1. In earlier versions you can 
rewrite query without a subquery:

SELECT c_table.id FROM c_table, users
WHERE c_table.user_id=users.id
AND user.locations_id=3
ORDER BY c_table.data_ora;

http://www.mysql.com/doc/en/Rewriting_subqueries.html


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Nested queries

2004-02-25 Thread vpendleton
What MySQL version are you running?

Original Message dated 2/25/04, 9:19:43 AM
Author: Gregorio [EMAIL PROTECTED]
Re: Nested queries:



This is the query i want to run but i doesn't work.
 
select id from c_table where users_id in (select id from users where 
locations_id=3) order by data_ora
 
But it gives me this error:
 
You have an error in your SQL syntax.  Check the manual that corresponds 
to your MySQL server version for the right syntax to use near 'select id 
from users where locations_id=3) order by data_ora
 
It seems correct to me. What's the problem?
 
 
Gregorio







___
  IncrediMail - il mondo della posta elettronica si è finalmente evoluto 
- Clicca Qui

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Nested queries

2004-02-25 Thread Alec . Cawley







Gregorio [EMAIL PROTECTED] wrote on 25/02/2004 15:19:43:

 This is the query i want to run but i doesn't work.

 select id from c_table where users_id in (select id from users where
 locations_id=3) order by data_ora

 But it gives me this error:

 You have an error in your SQL syntax.  Check the manual that
 corresponds to your MySQL server version for the right syntax to use
 near 'select id from users where locations_id=3) order by data_ora

 It seems correct to me. What's the problem?

Which MySQL version are you using.? Subselects (which is what this is
called) are only implemented from MySQL 4.1, which is still in beta. Before
that, you have to work around using joins - see
http://www.mysql.com/doc/en/Rewriting_subqueries.html.

I think your query might be phrased as

select id from c_table join users on c_table.users_id = users.id where
users.location_id = 3 ;

  Alec


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



nested queries

2003-01-23 Thread Justin French
Hi,

I'm trying to dig a bit deeper into mysql queries... I've come across an
application that i'm building which requires (it would seem on the surface)
many queries, do to the relational nature of the data.

The actual app is way too complex to explain, but I've come up with a
reasonably simple example.

Let's say i've got the cliche hierarchical menu system:

parent 1
child 1
grandchild 1
grandchild 2
child 2
grandchild 1
grandchild 2
child 3
child 4
parent 2
child 1
child 2
child 3
child 4
parent 3
child 1
child 2
child 3
child 4
grandchild 1
grandchild 2


From a table point of view, lets say I have 3 tables:

parent (id,name)
child (id, parentID, name)
grandchild (id, parentID, name)


Now, it's easy to query to get all the parents:

select * from parents


And it only takes 2 queries to get all the children of parent 2 (for
expanding one section of the menu)

select * from parents and
select * from children where parentID='2'


But when I decide I want to expand all the parents and children to show the
entire menu structure, it's a HEAP of queries.  Sure, I don't have to WRITE
them all, because PHP can do that for me in loops, but it occured to me that
I might be missing a HUGE piece of the puzzle in terms of what MySQL can
do...

can anyone help with a link to somewhere in the manual, or a tutorial that i
should be reading :)

thanks,

justin

mysql,query


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




ReE: nested queries

2003-01-23 Thread Roger Baklund
* Justin French
 I'm trying to dig a bit deeper into mysql queries... I've come across an
 application that i'm building which requires (it would seem on
 the surface)
 many queries, do to the relational nature of the data.

No. SQL was created to do queries on data of a relational nature, thus the
name RDBMS: Relational Database Management System. Most RDBMS's, including
mysql, use SQL as the main query language. It is of course capable of
querying multiple related tables in a single query.

 The actual app is way too complex to explain, but I've come up with a
 reasonably simple example.

 Let's say i've got the cliche hierarchical menu system:

 parent 1
 child 1
 grandchild 1
 grandchild 2
 child 2
 grandchild 1
 grandchild 2
 child 3
 child 4
 parent 2
 child 1
 child 2
 child 3
 child 4
 parent 3
 child 1
 child 2
 child 3
 child 4
 grandchild 1
 grandchild 2


 From a table point of view, lets say I have 3 tables:

 parent (id,name)
 child (id, parentID, name)
 grandchild (id, parentID, name)

This is not a good data model for this task. You only need one table:

item (id,parent,name)

This table is related to itself, using 'parent' as a foreign key.

 Now, it's easy to query to get all the parents:

 select * from parents

select * from item where parent is NULL;

 And it only takes 2 queries to get all the children of parent 2 (for
 expanding one section of the menu)

 select * from parents and
 select * from children where parentID='2'

select * from item where parent is NULL;
select * from item where parent=2;

...or, using one query:

select p.id,p.name,i.id,i.name
  from item as p
  left join item as i on
i.parent=p.id and
i.parent=2
  where p.parent is NULL;

 But when I decide I want to expand all the parents and children
 to show the
 entire menu structure, it's a HEAP of queries.  Sure, I don't
 have to WRITE
 them all, because PHP can do that for me in loops, but it occured
 to me that
 I might be missing a HUGE piece of the puzzle in terms of what MySQL can
 do...

You can also expand all items using only one query:

select p.id,p.name,i.id,i.name
  from item as p
  left join item as i on
i.parent=p.id
  where p.parent is NULL;

 can anyone help with a link to somewhere in the manual, or a
 tutorial that i should be reading :)

Read about JOINS and about database normalization:

URL: http://www.mysql.com/doc/en/JOIN.html 
URL: http://www.mysql.com/portal/sites/item-146.html 
URL: http://www.google.com/search?q=database+normalization 

HTH,

--
Roger


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Nested queries and joins

2002-06-16 Thread Balteo

Hello,

I have the following nested query that I would like to port to Mysql:


SELECT * FROM ad_catego
WHERE db_subcategory NOT IN
(SELECT rules.db_subcategory FROM rules
WHERE rules.db_login='$session_login')
AND db_category_int =2


The query uses two tables

desc ad_catego;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| db_subcategory | varchar(30) |  | PRI | |   |
| db_category| varchar(15) |  | | |   |
| db_category_int| smallint(6) |  | | 0   |   |
| db_subcategory_int | smallint(6) |  | | 0   |   |
++-+--+-+-+---+

desc rules;
++-+--+-++---+
| Field  | Type| Null | Key | Default| Extra |
++-+--+-++---+
| db_login   | varchar(15) |  | PRI ||   |
| db_subcategory | varchar(30) |  | PRI ||   |
| db_daterule| date|  | | -00-00 |   |
++-+--+-++---+

I tried several joins without success...  I would like to select all the 
subcategories that a user does not have.

Can anyone help?

Thanks in advance,

Balteo. 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Nested queries and joins

2002-06-16 Thread Peter Normann

SELECT ad_catego.* FROM ad_catego, db_subcategory 
WHERE ad_catego.db_subcategory=rules.db_subcategory
AND rules.db_category != '2'
AND rules.db_login !='$session_login';

?

Peter Normann
 
-Original Message-
From: Balteo [mailto:[EMAIL PROTECTED]] 
Sent: 17. juni 2002 00:12
To: [EMAIL PROTECTED]
Subject: Nested queries and joins


Hello,

I have the following nested query that I would like to port to Mysql:


SELECT * FROM ad_catego
WHERE db_subcategory NOT IN
(SELECT rules.db_subcategory FROM rules
WHERE rules.db_login='$session_login')
AND db_category_int =2


The query uses two tables

desc ad_catego;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| db_subcategory | varchar(30) |  | PRI | |   |
| db_category| varchar(15) |  | | |   |
| db_category_int| smallint(6) |  | | 0   |   |
| db_subcategory_int | smallint(6) |  | | 0   |   |
++-+--+-+-+---+

desc rules;
++-+--+-++---+
| Field  | Type| Null | Key | Default| Extra |
++-+--+-++---+
| db_login   | varchar(15) |  | PRI ||   |
| db_subcategory | varchar(30) |  | PRI ||   |
| db_daterule| date|  | | -00-00 |   |
++-+--+-++---+

I tried several joins without success...  I would like to select all the

subcategories that a user does not have.

Can anyone help?

Thanks in advance,

Balteo. 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Nested queries and joins

2002-06-16 Thread Peter Normann

Oops, I meant

SELECT ad_catego.* FROM ad_catego, db_subcategory 
WHERE ad_catego.db_subcategory=rules.db_subcategory
AND rules.db_category_int != '2'
AND rules.db_login !='$session_login';

?

Peter Normann

-Original Message-
From: Peter Normann [mailto:[EMAIL PROTECTED]] 
Sent: 16. juni 2002 18:15
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: RE: Nested queries and joins


SELECT ad_catego.* FROM ad_catego, db_subcategory 
WHERE ad_catego.db_subcategory=rules.db_subcategory
AND rules.db_category != '2'
AND rules.db_login !='$session_login';

?

Peter Normann
 
-Original Message-
From: Balteo [mailto:[EMAIL PROTECTED]] 
Sent: 17. juni 2002 00:12
To: [EMAIL PROTECTED]
Subject: Nested queries and joins


Hello,

I have the following nested query that I would like to port to Mysql:


SELECT * FROM ad_catego
WHERE db_subcategory NOT IN
(SELECT rules.db_subcategory FROM rules
WHERE rules.db_login='$session_login')
AND db_category_int =2


The query uses two tables

desc ad_catego;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| db_subcategory | varchar(30) |  | PRI | |   |
| db_category| varchar(15) |  | | |   |
| db_category_int| smallint(6) |  | | 0   |   |
| db_subcategory_int | smallint(6) |  | | 0   |   |
++-+--+-+-+---+

desc rules;
++-+--+-++---+
| Field  | Type| Null | Key | Default| Extra |
++-+--+-++---+
| db_login   | varchar(15) |  | PRI ||   |
| db_subcategory | varchar(30) |  | PRI ||   |
| db_daterule| date|  | | -00-00 |   |
++-+--+-++---+

I tried several joins without success...  I would like to select all the

subcategories that a user does not have.

Can anyone help?

Thanks in advance,

Balteo. 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Nested Queries

2002-01-30 Thread Victoria Reznichenko

Amit,

Wednesday, January 30, 2002, 7:45:13 AM, you wrote:

ADL Hi!!

ADL  I am trying to execute the following query. But it is giving 
ADL an error at select max(columnname). 

ADL select columname from tablename where columname1 = 
ADL select max(columnname) from tablename 

MySQL doesn't support subselects, look at: 
http://www.mysql.com/doc/A/N/ANSI_diff_Sub-selects.html
You can do it by another way, see at: 
http://www.mysql.com/doc/e/x/example-Maximum-row.html

ADL Thanks 
ADL Amit Lonkar 




-- 
For technical support contracts, goto https://order.mysql.com/
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
   ___/   www.mysql.com




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Nested Queries

2002-01-29 Thread Amit Dilip Lonkar


Hi!!

 I am trying to execute the following query. But it is giving an error at select 
max(columnname). 

select columname from tablename where columname1 = select max(columnname) from 
tablename 

Thanks 
Amit Lonkar 


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Nested Queries.

2001-12-21 Thread Richard Morton

Hi,

In alot of cases you can use the following query structure (extract from
MySQL 4.0.0alpha manual)to negotiate the need for Sub-Selects.

I hope this helps.

-Rich





1.4.4.1 Sub-selects

MySQL currently only supports sub selects of the form INSERT ... SELECT ...
and REPLACE ... SELECT  You can however use the function IN() in other
contexts.

In many cases you can rewrite the query without a sub-select:

SELECT * FROM table1 WHERE id IN (SELECT id FROM table2);

This can be re-written as:

SELECT table1.* FROM table1,table2 WHERE table1.id=table2.id;

The queries:

SELECT * FROM table1 WHERE id NOT IN (SELECT id FROM table2);
SELECT * FROM table1 WHERE NOT EXISTS (SELECT id FROM table2 where
table1.id=table2.id);

Can be rewritten as:

SELECT table1.* FROM table1 LEFT JOIN table2 ON table1.id=table2.id where
table2.id IS NULL

For more complicated subqueries you can often create temporary tables to
hold the subquery. In some cases, however this option will not work. The
most frequently encountered of these cases arises with DELETE statements,
for which standard SQL does not support joins (except in sub-selects). For
this situation there are two options available until subqueries are
supported by MySQL.

The first option is to use a procedural programming language (such as Perl
or PHP) to submit a SELECT query to obtain the primary keys for the records
to be deleted, and then use these values to construct the DELETE statement
(DELETE FROM ... WHERE ... IN (key1, key2, ...)).

The second option is to use interactive SQL to contruct a set of DELETE
statements automatically, using the MySQL extension CONCAT() (in lieu of the
standard || operator). For example:

SELECT CONCAT('DELETE FROM tab1 WHERE pkid = ', tab1.pkid, ';')
  FROM tab1, tab2
 WHERE tab1.col1 = tab2.col2;

You can place this query in a script file and redirect input from it to the
mysql command-line interpreter, piping its output back to a second instance
of the interpreter:

prompt mysql --skip-column-names mydb  myscript.sql | mysql mydb

MySQL 4.0 supports multi-table deletes that can be used to efficiently
delete rows based on information from one table or even from many tables at
the same time.


-Original Message-
From: Christian Andersson [mailto:[EMAIL PROTECTED]]
Sent: 20 December 2001 19:36
To: Larry Reiter; MySQL Mailing list
Subject: Re: Nested Queries.


Subqueries are not (yet)working in mysql, they will be implemented in the
4.0.x  or is it 4.x
which hopefully will be out very soon :-)

so if you are using the 3.23.xxx  you have to stick with temporary tables

/Christian

- Original Message -
From: Larry Reiter [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, December 20, 2001 7:58 PM
Subject: Nested Queries.


 I have constructed a query which requires a temporary table but I
 would rather use a nested query.  In other words, I want to extract a
 set of data and then use that set of data as a query against some
 other data.  Like some sort of SELECT within a SELECT.  Can I do this
 in MySQL?

 Cheers,

 LTR
 --
 Dr. Lawrence T. Reiter
 Postdoctoral Fellow
 Department of Biology, UCSD
 Bonner Hall Room 4221
 9500 Gilman Drive
 La Jolla, CA   92093-0349

 Phone: (858) 534-0442
 FAX: (858) 822-2044
 http://homophila.sdsc.edu
 email: [EMAIL PROTECTED]

 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail
[EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Nested Queries.

2001-12-20 Thread Larry Reiter

I have constructed a query which requires a temporary table but I
would rather use a nested query.  In other words, I want to extract a
set of data and then use that set of data as a query against some
other data.  Like some sort of SELECT within a SELECT.  Can I do this
in MySQL?

Cheers,

LTR
-- 
Dr. Lawrence T. Reiter
Postdoctoral Fellow
Department of Biology, UCSD
Bonner Hall Room 4221
9500 Gilman Drive
La Jolla, CA   92093-0349

Phone: (858) 534-0442
FAX: (858) 822-2044
http://homophila.sdsc.edu
email: [EMAIL PROTECTED]

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Nested Queries.

2001-12-20 Thread Christian Andersson

Subqueries are not (yet)working in mysql, they will be implemented in the
4.0.x  or is it 4.x
which hopefully will be out very soon :-)

so if you are using the 3.23.xxx  you have to stick with temporary tables

/Christian

- Original Message -
From: Larry Reiter [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, December 20, 2001 7:58 PM
Subject: Nested Queries.


 I have constructed a query which requires a temporary table but I
 would rather use a nested query.  In other words, I want to extract a
 set of data and then use that set of data as a query against some
 other data.  Like some sort of SELECT within a SELECT.  Can I do this
 in MySQL?

 Cheers,

 LTR
 --
 Dr. Lawrence T. Reiter
 Postdoctoral Fellow
 Department of Biology, UCSD
 Bonner Hall Room 4221
 9500 Gilman Drive
 La Jolla, CA   92093-0349

 Phone: (858) 534-0442
 FAX: (858) 822-2044
 http://homophila.sdsc.edu
 email: [EMAIL PROTECTED]

 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)

 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Nested Queries in MySQl

2001-08-07 Thread William R. Mussatto

You can also do it programatically.  I find, even with MySQL that this is 
faster since it avoids the NxM intermediate table creation where one can 
limit the number of rows intially. I'm using Debian so I'm stuck on .22 
for now, this might change in .23.  It would definitely be the way to go 
for you nested queries. 

On Tue, 7 Aug 2001, Grigory Bakunov 
wrote:

 Date: Tue, 7 Aug 2001 09:57:52 +0500
 From: Grigory Bakunov [EMAIL PROTECTED]
 To: Steven Robillard [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: Nested Queries in MySQl
 
 Date |6 Aug 2001 19:59:46 -0700
 From |Steven Robillard [EMAIL PROTECTED]
 
 Hello!
 
 SR Hi all, I have not been using MySQL for too long but have been using SQL7.0 for 
a while now, so I am generally familiar with the structure.  
 SR My basic problem right now is trying to figure out how to get MySQL to do nested 
queries such as ...
 SR select count(*) from (select count(*) as A, group_col from my_table group by 
group_col) as B
 SR Could someone help me out with getting the nested query to work, (I know this 
can be done here with a distinct but work with me here.)  Thanks in advance.
 
 MySQL does'nt support nested queries now.
 You can try to play with JOIN syntax
 http://www.mysql.com/doc/J/O/JOIN.html
 
 ___
Truly yours, Grigory Bakunov
   ASPLinux Support Team
  http://www.asplinux.ru
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 

Sincerely,

William Mussatto, Senior Systems Engineer
CyberStrategies, Inc
ph. 909-920-9154 ext. 27


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Nested Queries in MySQl

2001-08-06 Thread Steven Robillard

Hi all, I have not been using MySQL for too long but have been using SQL7.0 for a 
while now, so I am generally familiar with the structure.  

My basic problem right now is trying to figure out how to get MySQL to do nested 
queries such as ...

select count(*) from (select count(*) as A, group_col from my_table group by 
group_col) as B

Could someone help me out with getting the nested query to work, (I know this can be 
done here with a distinct but work with me here.)  Thanks in advance.


Steve



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: Nested Queries in MySQl

2001-08-06 Thread Grigory Bakunov

Date |6 Aug 2001 19:59:46 -0700
From |Steven Robillard [EMAIL PROTECTED]

Hello!

SR Hi all, I have not been using MySQL for too long but have been using SQL7.0 for a 
while now, so I am generally familiar with the structure.  
SR My basic problem right now is trying to figure out how to get MySQL to do nested 
queries such as ...
SR select count(*) from (select count(*) as A, group_col from my_table group by 
group_col) as B
SR Could someone help me out with getting the nested query to work, (I know this can 
be done here with a distinct but work with me here.)  Thanks in advance.

MySQL does'nt support nested queries now.
You can try to play with JOIN syntax
http://www.mysql.com/doc/J/O/JOIN.html

___
   Truly yours, Grigory Bakunov
  ASPLinux Support Team
 http://www.asplinux.ru

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: subqueries / nested queries

2001-02-01 Thread Benjamin Pflugmann

Hi.

For many sub-queries, there exists a one-query work-around.

Most of the rest, you can work-around with some commands.

And then, there are a few around which one has to work in application.

There is a section in the manual about how to handle the lack of
sub-queries, which explains the most common work-around(s).

If you still don't know how to rewrite your query, post the sub-query
you want to / would use, and probably someone will give you the right
pointer where to start.

Bye,

Benjamin.


On Fri, Feb 02, 2001 at 11:33:11AM +1030, [EMAIL PROTECTED] wrote:

 I understand that MySQL does not support subqueries or nested
 queries. Is there a simple workaround or do I have to do a number of
 queries and manipulate them outside of MySQL? I am using PHP for
 server side code. Where can I look for answers?
 
 Terence

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php