PDA

View Full Version : How to create this text file?


mishkan
Wed 31st Jul '02, 9:36pm
Hi :),

Table = user
Fields = username, email

Table = userfield
Fields = field5

I would like to create a text file, that contains 2 fields for every individual in my database...
field5 if it's not blank... or else username if field5 is blank.
email.

I'd like the output to be like this...

field5 or username
email

field5 or username
email

field5 or username
email



Could someone please explain how I can do this? I just started to learn MySQL today, so I'm really a total beginner... please keep it simple... :D.

Thanks in advance!

mishkan :)

mishkan
Sun 11th Aug '02, 12:49am
bumping...

This is what I have, but it's not correct...

select email, username, field5
from user, userfield
where user.userid = userfield.userid;

If anyone can please help me out, it would be much appreciated.
Thanks in advance,

mishkan :)

mishkan
Mon 12th Aug '02, 5:32pm
... very gentle and hopeful bump... please? :D :D :D

Is there no response because this can't be done with MySQL?

megahard
Mon 12th Aug '02, 5:57pm
maybe if u explain it in a way people understand then u might get a response.

its ded easy, but do u want a seperate txt file for each person or what, i dont get wut ur on about.

yes im tired so u'll have to 4giv the shortcut typin

WingMan
Tue 13th Aug '02, 7:00am
Is this anything close ..... ?

NB: char(10) is the ASCII end of line character


Select 'Table = ' + <user> + char(10),
'Fields = ' + <username> + ',' + <email> + char(10)
+ char(10)
From <TableName>
Where field5 = ''
Union
Select 'Table = ' + <userfield> + char(10),
'Fields = ' + <field5> + char(10)
+ char(10)
From <TableName>
Where field5 <> ''

mishkan
Tue 13th Aug '02, 2:02pm
Originally posted by megahard
maybe if u explain it in a way people understand then u might get a response.

its ded easy, but do u want a seperate txt file for each person or what, i dont get wut ur on about.
Oh gee, I didn't realize it was unclear... thanks so much for the feedback! Okay, please let me try again.

(1) In the table called "user", there are these fields... username and email. Typically, on my board, username will contain the individual's real name. But, some users have an "anonymous" name in username. For those users, I put their real name in a separate field. That separate field is called field5, and it's in the table called "userfield".

In other words, if field5 is blank, then the real name is in username. If field5 is not blank, then it contains the real name.

(2) I would like to create a text file, with extension "txt", on my own computer. The file should contain the real name and the email address for every individual in a particular user group. It should look like this...

real name for user 1
email address 1

real name for user 2
email address 2

real name for user 3
email address 3

... and so on...

======

WingMan, does your code accomplish this?

Thanks again for your responses! :)

WingMan
Fri 16th Aug '02, 7:34am
Well it won't produce the text file straight off, but i think it will produce the dataset you are looking for. You can test it using the MySQL Shell (sh) Assuming you have SSH access?.

This only way i know to make the text file is to either copy and paste the results or pipe your MySQL results out using a shell script(sh), but i'm sure there must be a better way ??