So I am learning database/mySQL and how to use DBI, and thus far the basics seem straight-forward. However, what if I wanted to insert a column into an existing table. Say I had already a table, "Cars":
idCars Car
------ ---
1 MiniCooper
2 Civic
3 Camry
4 Accord
And I realized I wanted to add whether the car was a sedan, compact, subcompact and I coded a table, "Size":
idSize Size
------ ----
1 subcompact
2 compact
3 sedan
I am assuming I would want to insert a column, "Size", in table, "Cars", as a foreign key to idSize. I already have in tab-delimited file a two column table with `idCars` and `idSize` to insert. I am wondering if there is something similar to VLOOKUP in mySQL, especially if I have like 300 entries? From what I have read so far it seems like I would have to fetch the data first, then compare it locally to my file, prepare it as a column in the same order as table, "Cars", and then insert that column into "Cars"? Or should I fetch one row at a time and check it against my file and insert value at that row, and iterate this?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.