Re: --- How to query results of a query?
On Wed, Jan 15, 2003 at 11:55:44PM +, [EMAIL PROTECTED] wrote: please look at page 194 of the reference manual... (and if so how do you ask MySQL to create a temp table from the results of aquery?) here's an example: mysql create temporary table tmp (name varchar(20), owner varchar(20, species varchar(10)); mysql insert into tmp select name, owner, species from pet where species='Dog'; Or in 1 go: create temporary table tmp select name, owner, species from pet where species='Dog'; Of it is small: create temporary table tmp type=heap select name, owner, species from pet where species='Dog'; for memory based one. Harmen (Sql, select, etc) -- The Moon is Waxing Gibbous (95% of Full) tty.nl - 2dehands.nl: 59340 - 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: --- How to query results of a query?
If you're in Java you can call getMetaData on the ResultSet, and then call methods on that (ResultSetMetaData) to determine number of columns, and type of each column. This avoids the steps of creating/deleting a temp table. What language are you using? From: Will Standley [EMAIL PROTECTED] Subject: --- How to query results of a query? Date: 16/01/2003 6:42:05 To: [EMAIL PROTECTED] How do you query the table that is the results of a query? Must you ask MySQL to... ...create a temporary table form the results of the first query ...then query that temporary table ...then delete the temp table when you are done? (and if so how do you ask MySQL to create a temp table from the results of a query?) Is there a better and faster way to do this with minimum burden on the web server with the db on it? Thanks for any help. Will - 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 This message was sent through MyMail http://www.mymail.com.au - 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: --- How to query results of a query?
Hello. Please start a new thread instead of replying to an existing one. Or else, your message will be sorted with the original thread for people with decent mail readers. On Wed 2003-01-15 at 14:42:05 -0500, [EMAIL PROTECTED] wrote: How do you query the table that is the results of a query? By a sub-query. Since MySQL supports sub-queries only since version 4.1 (alpha), you have to work around this limitiation. The general answer can be found in the manual: http://www.mysql.com/doc/en/ANSI_diff_Sub-selects.html Must you ask MySQL to... ...create a temporary table form the results of the first query ...then query that temporary table ...then delete the temp table when you are done? That is one possible solution (also mentioned in the manual page I cited). The third step optional if you use the TEMPORARY keyword with the table, because it will be deleted automatically when the conncetion is closed. (and if so how do you ask MySQL to create a temp table from the results of a query?) See http://www.mysql.com/doc/en/example-Maximum-column-group-row.html, which shows a work-around to a query which typically needs a sub-select. Is there a better and faster way to do this with minimum burden on the web server with the db on it? No. Btw, in the cases where you cannot rewrite a sub-select into a join, most often an RDBMS will so the equivalent of a temporary table. So there is not much loss, except for the additional transfer and parsing of the queries. HTH, Benjamin. -- [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:--- How to query results of a query?
please look at page 194 of the reference manual... (and if so how do you ask MySQL to create a temp table from the results of aquery?) here's an example: mysql create temporary table tmp (name varchar(20), owner varchar(20, species varchar(10)); mysql insert into tmp select name, owner, species from pet where species='Dog'; These 2 statements put the results of the select name, owner, species from pet where... query in the temporary table tmp. thanks Nasser. == How do you query the table that is the results of a query? Must you ask MySQL to... create a temporary table form the results of the first query then query that temporary table then delete the temp table when you are done? (and if so how do you ask MySQL to create a temp table from the results of a query?) Is there a better and faster way to do this with minimum burden on the web server with the db on it? Thanks for any help. Will - 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