Import MYSQL table information from .sql file

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default mySQL Question

    If I have created a .sql file in my notepad named tables.sql and laved it in
    my inetpub folder what commands do I have to enter at the mySQL command
    prompt to get it to import the table information into my database?

    Thanks for any help,

    Brad


    Brad Brevet Guest

  2. Similar Questions and Discussions

    1. Export Querries from Flash 8 to MySQL and Import Datafrom MySQL
      Hi friends, I am making a web site for a customer and i need to import data from MySQL Database but i don't know how to do it. I would appreciate...
    2. import Text file in MySQL table
      I've a text file I've downloaded wich contains the datas I must use to fill a table. (postal code and cities). Here is the structure of my text...
    3. Import text file into database table
      I need to build a web page that allows the user to select a text file and click a button to import the file into a database table. Does anyone...
    4. Import .sql file into MySQL DB ?
      Jerry T <Jerry@ nothanks.com> wrote in message news:<drgkjv03hrpc69p2tt5v0pjmfdspqlnesf@4ax.com>... phpMyAdmin has a functionality to execute...
    5. Add a database as a table of information
      I have an Access database that I would like to simply add to a table so the content of the database can be listed, while exluding some of the...
  3. #2

    Default re: Import MYSQL table information from .sql file

    try here:

    [url]http://www.mysql.com/doc/en/mysqlimport.html[/url]


    On Sat, 19 Jul 2003 18:52:54 -0700, "Brad Brevet"
    <bradbrevet@hotmail.com> wrote:
    >If I have created a .sql file in my notepad named tables.sql and laved it in
    >my inetpub folder what commands do I have to enter at the mySQL command
    >prompt to get it to import the table information into my database?
    >
    >Thanks for any help,
    >
    >Brad
    >
    Ed Guest

  4. #3

    Default re: Import MYSQL table information from .sql file

    mysql -u username -p -vvv < tables.sql

    Joseph

    "Brad Brevet" <bradbrevet@hotmail.com> wrote in message news:bfcsog$e5p$1@forums.macromedia.com...
    > If I have created a .sql file in my notepad named tables.sql and laved it in
    > my inetpub folder what commands do I have to enter at the mySQL command
    > prompt to get it to import the table information into my database?
    >
    > Thanks for any help,
    >
    > Brad
    >
    >
    Joseph Szobody Guest

  5. #4

    Question Import MYSQL table information from .sql file

    On Sun, 20 Jul 2003 03:05:31 GMT, Ed <ed.nospam@mind.spring.com>
    wrote:
    >try here:
    >
    >[url]http://www.mysql.com/doc/en/mysqlimport.html[/url]
    >
    >
    >On Sat, 19 Jul 2003 18:52:54 -0700, "Brad Brevet"
    ><bradbrevet@hotmail.com> wrote:
    >
    >>If I have created a .sql file in my notepad named tables.sql and laved it in
    >>my inetpub folder what commands do I have to enter at the mySQL command
    >>prompt to get it to import the table information into my database?
    >>
    >>Thanks for any help,
    >>
    >>Brad
    >>
    If you use a GUI, like dbmanager ([url]www.dbtools.com.br[/url]) or phpmyadmin
    ([url]www.phpmyadmin.net[/url]), it becomes easy to import. I'm a bit lazy,
    myself - I try to avoid the command line if I can.


    Paul Taylor
    Paul Taylor Guest

  6. #5

    Default MySQL Question

    I am using MYSQL and have multiple databases. I can write code to connect to
    one database or the other. How do I write a sql statement that will allow me
    to access tables in two different databases?

    Thank You...




    Philip Ladin Guest

  7. #6

    Default MYSQL Question

    I am using MYSQL and have multiple databases. I can write code to connect to
    one database or the other. How do I write a sql statement that will allow me
    to access tables in two different databases?

    Thank You...




    Philip Ladin Guest

  8. #7

    Default re: Import MYSQL table information from .sql file

    Den Fri, 10 Oct 2003 15:28:37 -0400. skrev Philip Ladin:
    > I am using MYSQL and have multiple databases. I can write code to connect
    > to one database or the other. How do I write a sql statement that will
    > allow me to access tables in two different databases?
    >
    > Thank You...
    You create two connections and remembers to add which connection every
    request should go to.

    $link1 = mysql_connect("localhost", "mysql_user", "mysql_password")
    or die("Could not connect: " . mysql_error());
    print ("Connected successfully");
    mysql_close($link);
    $link2 = mysql_connect("localhost", "mysql_user", "mysql_password")
    or die("Could not connect: " . mysql_error());
    print ("Connected successfully");
    mysql_close($link);
    mysql_select_db("foo",$link1);
    mysql_select_db("bar",$link2);

    mysql_query("select * from table1", $link1);
    mysql_query("select * from table1", $link2);

    etc.

    --
    Hilsen/Sincerely, Michael Rasmussen

    En windows admin er en person, for hvem den største bedrift er, at
    lave konfiguration af serveren med trial and error via en gui.

    Michael Rasmussen Guest

  9. #8

    Default re: Import MYSQL table information from .sql file

    Thank you...

    "Michael Rasmussen" <mir@datanom.net> wrote in message
    news:pan.2003.10.10.19.55.20.227967@datanom.net...
    > Den Fri, 10 Oct 2003 15:28:37 -0400. skrev Philip Ladin:
    >
    > > I am using MYSQL and have multiple databases. I can write code to
    connect
    > > to one database or the other. How do I write a sql statement that will
    > > allow me to access tables in two different databases?
    > >
    > > Thank You...
    > You create two connections and remembers to add which connection every
    > request should go to.
    >
    > $link1 = mysql_connect("localhost", "mysql_user", "mysql_password")
    > or die("Could not connect: " . mysql_error());
    > print ("Connected successfully");
    > mysql_close($link);
    > $link2 = mysql_connect("localhost", "mysql_user", "mysql_password")
    > or die("Could not connect: " . mysql_error());
    > print ("Connected successfully");
    > mysql_close($link);
    > mysql_select_db("foo",$link1);
    > mysql_select_db("bar",$link2);
    >
    > mysql_query("select * from table1", $link1);
    > mysql_query("select * from table1", $link2);
    >
    > etc.
    >
    > --
    > Hilsen/Sincerely, Michael Rasmussen
    >
    > En windows admin er en person, for hvem den største bedrift er, at
    > lave konfiguration af serveren med trial and error via en gui.
    >

    Philip Ladin Guest

  10. #9

    Default re: Import MYSQL table information from .sql file

    Philip Ladin wrote:
    > I am using MYSQL and have multiple databases. I can write code to connect to
    > one database or the other. How do I write a sql statement that will allow me
    > to access tables in two different databases?
    multiple databases on the same server? easy :-)

    <?php
    $conn = mysql_connect('server', 'user', 'pass');


    $sql = "select a.col1, a.col2, b.col2, b.col3"
    . "from db1.table a, db2.table b" # a is in db1; b is in db2
    . "where a.id=b.id";


    $res = mysql_query($sql);
    echo '<table>';
    while ($row = mysql_fetch_row($res)) {
    echo '<tr>';
    foreach ($row as $x) {
    echo "<td>$x</td>";
    }
    echo '</tr>';
    }
    echo '</table>';
    ?>

    --
    I have a spam filter working.
    To mail me include "urkxvq" (with or without the quotes)
    in the subject line, or your mail will be ruthlessly discarded.
    Pedro Guest

  11. #10

    Default re: Import MYSQL table information from .sql file

    Thank you...
    "Pedro" <hexkid@hotpop.com> wrote in message
    news:bm75dt$jcgkf$1@ID-203069.news.uni-berlin.de...
    > Philip Ladin wrote:
    > > I am using MYSQL and have multiple databases. I can write code to
    connect to
    > > one database or the other. How do I write a sql statement that will
    allow me
    > > to access tables in two different databases?
    >
    > multiple databases on the same server? easy :-)
    >
    > <?php
    > $conn = mysql_connect('server', 'user', 'pass');
    >
    >
    > $sql = "select a.col1, a.col2, b.col2, b.col3"
    > . "from db1.table a, db2.table b" # a is in db1; b is in db2
    > . "where a.id=b.id";
    >
    >
    > $res = mysql_query($sql);
    > echo '<table>';
    > while ($row = mysql_fetch_row($res)) {
    > echo '<tr>';
    > foreach ($row as $x) {
    > echo "<td>$x</td>";
    > }
    > echo '</tr>';
    > }
    > echo '</table>';
    > ?>
    >
    > --
    > I have a spam filter working.
    > To mail me include "urkxvq" (with or without the quotes)
    > in the subject line, or your mail will be ruthlessly discarded.

    Philip Ladin Guest

  12. #11

    Default re: Import MYSQL table information from .sql file

    Carved in mystic runes upon the very living rock, the last words of
    Philip Ladin of alt.comp.lang.php make plain:
    > I am using MYSQL and have multiple databases. I can write code to
    > connect to one database or the other. How do I write a sql statement
    > that will allow me to access tables in two different databases?
    I'm not a total MySQL expert, but I believe the short answer is: you can't.

    --
    Alan Little
    Phorm PHP Form Processor
    [url]http://www.phorm.com/[/url]
    Alan Little Guest

  13. #12

    Default re: Import MYSQL table information from .sql file

    "Philip Ladin" <philipl@amalla.com> wrote in message
    news:R_Ehb.31144$Sn1.11518@bignews4.bellsouth.net. ..
    > Thank you...
    > "Pedro" <hexkid@hotpop.com> wrote in message
    > news:bm75dt$jcgkf$1@ID-203069.news.uni-berlin.de...
    > > Philip Ladin wrote:
    > > > I am using MYSQL and have multiple databases. I can write code to
    > connect to
    > > > one database or the other. How do I write a sql statement that will
    > allow me
    > > > to access tables in two different databases?
    > >
    > > multiple databases on the same server? easy :-)
    > >
    > > <?php
    > > $conn = mysql_connect('server', 'user', 'pass');
    > >
    > >
    > > $sql = "select a.col1, a.col2, b.col2, b.col3"
    > > . "from db1.table a, db2.table b" # a is in db1; b is in db2
    > > . "where a.id=b.id";
    > >
    > >
    > > $res = mysql_query($sql);
    > > echo '<table>';
    > > while ($row = mysql_fetch_row($res)) {
    > > echo '<tr>';
    > > foreach ($row as $x) {
    > > echo "<td>$x</td>";
    > > }
    > > echo '</tr>';
    > > }
    > > echo '</table>';
    > > ?>
    I would also suggest that a requirement to query across databases means that
    your database structure has been poorly designed.

    Paulus


    Paulus Magnus Guest

  14. #13

    Default re: Import MYSQL table information from .sql file


    On 10-Oct-2003, Alan Little <alan@n-o-s-p-a-m-phorm.com> wrote:
    > > I am using MYSQL and have multiple databases. I can write code to
    > > connect to one database or the other. How do I write a sql statement
    > > that will allow me to access tables in two different databases?
    >
    > I'm not a total MySQL expert, but I believe the short answer is: you
    > can't.
    If the databases are on the same server you can.

    select * from db1.table1, db2.table2 where
    db1.table1.field1=db2.table2.field2

    --
    Tom Thackrey
    [url]www.creative-light.com[/url]
    tom (at) creative (dash) light (dot) com
    do NOT send email to [email]jamesbutler@willglen.net[/email] (it's reserved for spammers)
    Tom Thackrey Guest

  15. #14

    Default re: Import MYSQL table information from .sql file

    On Sat, 11 Oct 2003 06:53:44 +0000 (UTC), "Paulus Magnus"
    <paulus.magnus@loves-spam.com> scrawled:
    >"Philip Ladin" <philipl@amalla.com> wrote in message
    >news:R_Ehb.31144$Sn1.11518@bignews4.bellsouth.net ...
    >> Thank you...
    >> "Pedro" <hexkid@hotpop.com> wrote in message
    >> news:bm75dt$jcgkf$1@ID-203069.news.uni-berlin.de...
    >> > Philip Ladin wrote:
    >> > > I am using MYSQL and have multiple databases. I can write code to
    >> connect to
    >> > > one database or the other. How do I write a sql statement that will
    >> allow me
    >> > > to access tables in two different databases?
    >> >
    >> > multiple databases on the same server? easy :-)
    >> >
    >> > <?php
    >> > $conn = mysql_connect('server', 'user', 'pass');
    >> >
    >> >
    >> > $sql = "select a.col1, a.col2, b.col2, b.col3"
    >> > . "from db1.table a, db2.table b" # a is in db1; b is in db2
    >> > . "where a.id=b.id";
    >> >
    >> >
    >> > $res = mysql_query($sql);
    >> > echo '<table>';
    >> > while ($row = mysql_fetch_row($res)) {
    >> > echo '<tr>';
    >> > foreach ($row as $x) {
    >> > echo "<td>$x</td>";
    >> > }
    >> > echo '</tr>';
    >> > }
    >> > echo '</table>';
    >> > ?>
    >
    >I would also suggest that a requirement to query across databases means that
    >your database structure has been poorly designed.
    >
    May not be - it may be that you have a core of data in one database, and
    that you have a number of optional additional data in a number of satellite
    databases, these all have a common schema but may be produced in house,
    or obtained from external sources.

    This allows for the arbitrary combination of data from a number of
    different sources without having to have the bastardisation of table names
    to produce table "mydata_feature" instead of "mydata.feature".

    On a large project I work on (not in PHP) we do this a lot to achieve quite
    complex data manipulations (at the last count we were placing over
    100Gbytes of data in the public domain)

    But we also have a layer that can do this join in software rather than
    using the niceness of using MySQLs database join features - it just results
    in a lot more queries a lot more code and a loss of speed, but does work
    when the databases are not collocated.


    James Guest

  16. #15

    Default re: Import MYSQL table information from .sql file


    "James" <newsgroup@black-panther.freeserve.co.uk> wrote in message
    news:3f87b403.98111186@news.freeserve.com...
    > On Sat, 11 Oct 2003 06:53:44 +0000 (UTC), "Paulus Magnus"
    > <paulus.magnus@loves-spam.com> scrawled:
    >
    > >"Philip Ladin" <philipl@amalla.com> wrote in message
    > >news:R_Ehb.31144$Sn1.11518@bignews4.bellsouth.net ...
    > >> Thank you...
    > >> "Pedro" <hexkid@hotpop.com> wrote in message
    > >> news:bm75dt$jcgkf$1@ID-203069.news.uni-berlin.de...
    > >> > Philip Ladin wrote:
    > >> > > I am using MYSQL and have multiple databases. I can write code to
    > >> connect to
    > >> > > one database or the other. How do I write a sql statement that will
    > >> allow me
    > >> > > to access tables in two different databases?
    > >> >
    > >> > multiple databases on the same server? easy :-)
    > >> >
    > >> > <?php
    > >> > $conn = mysql_connect('server', 'user', 'pass');
    > >> >
    > >> >
    > >> > $sql = "select a.col1, a.col2, b.col2, b.col3"
    > >> > . "from db1.table a, db2.table b" # a is in db1; b is in db2
    > >> > . "where a.id=b.id";
    > >> >
    > >> >
    > >> > $res = mysql_query($sql);
    > >> > echo '<table>';
    > >> > while ($row = mysql_fetch_row($res)) {
    > >> > echo '<tr>';
    > >> > foreach ($row as $x) {
    > >> > echo "<td>$x</td>";
    > >> > }
    > >> > echo '</tr>';
    > >> > }
    > >> > echo '</table>';
    > >> > ?>
    > >
    > >I would also suggest that a requirement to query across databases means
    that
    > >your database structure has been poorly designed.
    > >
    >
    > May not be - it may be that you have a core of data in one database, and
    > that you have a number of optional additional data in a number of
    satellite
    > databases, these all have a common schema but may be produced in house,
    > or obtained from external sources.
    Very true, I just think in the majority of cases (99% of all the occasions
    that I've seen it) that using more than one database is an indication of a
    poorly designed data structure.

    Paulus


    Paulus Magnus Guest

  17. #16

    Default re: Import MYSQL table information from .sql file


    Alternitavely if they are on different servers you can do a lot of work
    in the code.

    -----Original Message-----
    From: Tom Thackrey [mailto:use.signature@nospam.com]
    Posted At: Saturday, 11 October 2003 4:38 PM
    Posted To: php
    Conversation: MYSQL Question
    Subject: Re: MYSQL Question



    On 10-Oct-2003, Alan Little <alan@n-o-s-p-a-m-phorm.com> wrote:
    > > I am using MYSQL and have multiple databases. I can write code to
    > > connect to one database or the other. How do I write a sql statement
    > > that will allow me to access tables in two different databases?
    >
    > I'm not a total MySQL expert, but I believe the short answer is: you
    > can't.
    If the databases are on the same server you can.

    select * from db1.table1, db2.table2 where
    db1.table1.field1=db2.table2.field2

    --
    Tom Thackrey
    [url]www.creative-light.com[/url]
    tom (at) creative (dash) light (dot) com
    do NOT send email to [email]jamesbutler@willglen.net[/email] (it's reserved for
    spammers)

    Rohan Hawthorne Guest

  18. #17

    Default re: Import MYSQL table information from .sql file

    I agree with you that in most cases, spreading data across disparate
    databases is a poor design. In my case, I was converting some data from
    different sources and was writing some maintenance scripts....

    "Paulus Magnus" <paulus.magnus@loves-spam.com> wrote in message
    news:bm8dlg$m2h$1@titan.btinternet.com...
    >
    > "James" <newsgroup@black-panther.freeserve.co.uk> wrote in message
    > news:3f87b403.98111186@news.freeserve.com...
    > > On Sat, 11 Oct 2003 06:53:44 +0000 (UTC), "Paulus Magnus"
    > > <paulus.magnus@loves-spam.com> scrawled:
    > >
    > > >"Philip Ladin" <philipl@amalla.com> wrote in message
    > > >news:R_Ehb.31144$Sn1.11518@bignews4.bellsouth.net ...
    > > >> Thank you...
    > > >> "Pedro" <hexkid@hotpop.com> wrote in message
    > > >> news:bm75dt$jcgkf$1@ID-203069.news.uni-berlin.de...
    > > >> > Philip Ladin wrote:
    > > >> > > I am using MYSQL and have multiple databases. I can write code to
    > > >> connect to
    > > >> > > one database or the other. How do I write a sql statement that
    will
    > > >> allow me
    > > >> > > to access tables in two different databases?
    > > >> >
    > > >> > multiple databases on the same server? easy :-)
    > > >> >
    > > >> > <?php
    > > >> > $conn = mysql_connect('server', 'user', 'pass');
    > > >> >
    > > >> >
    > > >> > $sql = "select a.col1, a.col2, b.col2, b.col3"
    > > >> > . "from db1.table a, db2.table b" # a is in db1; b is in
    db2
    > > >> > . "where a.id=b.id";
    > > >> >
    > > >> >
    > > >> > $res = mysql_query($sql);
    > > >> > echo '<table>';
    > > >> > while ($row = mysql_fetch_row($res)) {
    > > >> > echo '<tr>';
    > > >> > foreach ($row as $x) {
    > > >> > echo "<td>$x</td>";
    > > >> > }
    > > >> > echo '</tr>';
    > > >> > }
    > > >> > echo '</table>';
    > > >> > ?>
    > > >
    > > >I would also suggest that a requirement to query across databases means
    > that
    > > >your database structure has been poorly designed.
    > > >
    > >
    > > May not be - it may be that you have a core of data in one database, and
    > > that you have a number of optional additional data in a number of
    > satellite
    > > databases, these all have a common schema but may be produced in house,
    > > or obtained from external sources.
    >
    > Very true, I just think in the majority of cases (99% of all the occasions
    > that I've seen it) that using more than one database is an indication of a
    > poorly designed data structure.
    >
    > Paulus
    >
    >

    Philip Ladin Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139