This is a discussion on Subtables (newbie) within the MySQL Database forums, part of the Database Forums category; Hi all: Suppose that I have a table called library concerning the books from a library. If I type SELECT ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi all:
Suppose that I have a table called library concerning the books from a library. If I type SELECT title, author FROM library; I get the two columns of the table which contain the titles and the authors. Is it possible to save this as another table? In other words, I would like to now how to extract a subtable from a table. Best regards, Jose Carlos Santos |
|
|||
|
José Carlos Santos wrote:
> Hi all: > > Suppose that I have a table called library concerning the books from a > library. If I type > > SELECT title, author FROM library; > > I get the two columns of the table which contain the titles and the > authors. Is it possible to save this as another table? > > In other words, I would like to now how to extract a subtable from a > table. > > Best regards, > > Jose Carlos Santos http://dev.mysql.com/doc/refman/5.1/...ate-table.html http://dev.mysql.com/doc/refman/5.1/...rt-select.html -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
|
|||
|
On 02-05-2006 12:25, Jerry Stuckle wrote:
>> Suppose that I have a table called library concerning the books from a >> library. If I type >> >> SELECT title, author FROM library; >> >> I get the two columns of the table which contain the titles and the >> authors. Is it possible to save this as another table? >> >> In other words, I would like to now how to extract a subtable from a >> table. > > http://dev.mysql.com/doc/refman/5.1/...ate-table.html > http://dev.mysql.com/doc/refman/5.1/...rt-select.html Thinks. I did a search at http://dev.mysql.com/doc/refman/5.1/en/ before posting here, but using the word "subtable". I didn't know that the magic word was "insert". Best regards, Jose Carlos Santos |
|
|||
|
=?ISO-8859-1?Q?Jos=E9_Carlos_Santos?= <jcsantos@fc.up.pt> wrote:
> Suppose that I have a table called library concerning the books from a > library. If I type > > SELECT title, author FROM library; > > I get the two columns of the table which contain the titles and the > authors. Is it possible to save this as another table? > > In other words, I would like to now how to extract a subtable from a > table. In SQL there is no concept like a SUBTABLE. But there is a thing called a VIEW which can be seen as kind of a subtable. Example: CREATE VIEW library_short AS SELECT title, author FROM library; would create the VIEW `library_short`, containing the `title` and `author` columns from table `library`. This VIEW could be used just like an ordinary table in your SQL statements. SELECT * FROM library_short WHERE author LIKE '%Goethe%'; For more details on VIEWs, please consult the MySQL manual and/or a SQL textbook of your choice. HTH, XL -- Axel Schwenke, Senior Software Developer, MySQL AB Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/ MySQL User Forums: http://forums.mysql.com/ |