query / data extraction into outfile help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • b0red
    New Member
    • Jan 2007
    • 1

    query / data extraction into outfile help

    Hi All,
    Thanks for taking the time to read this post, I appreciate it.

    Two problems

    Problem 1
    ---------
    I need help with a query the table contains 35 odd columns I only want fname, lname,and age . I'd like to dump the results as a single file in the following format:
    fname:lname:age
    As after I have dumped the results I need to import them into another app that uses the format fname:lname:age .
    I'm sure this can be done but need some pointers.

    Problem 2
    ---------

    A similar issue , this time I have database dumps in table.sql format. Again I need to extract the columns fname,lname,age into another file and alter the format to fname:lname:age .
    Am I going to have to import the data into a temporary table then extract it or can i extract the information directly.
    I've been doing it with excel as it's the only tool I know but with 20-30k records it's a pain.

    G'wan folks I know you can help.

    Best
    b0red
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    You can extract the values into an output file, like
    Code:
    SELECT fname,lname,age FROM table INTO OUTFILE 'fn.ft'
    FIELDS TERMINATED BY ':' LINES TERMINATED BY '\n';
    Your second problem: unless you want to write a program to change your .sql file, I advise to just execute the .sql file into a temp table, and do a similar SELECT as above.

    Ronald :cool:

    Comment

    Working...