timestamp and comparing different tables

Tags:
SQL
hello i'm quite a beginner at this stuff.. right now i have a very basic database: 2 tables: Table 1: Handheld_tags: 2 columns Column 1: tag_in varchar(16) Column 2: time_in timestamp Table 2: Registered_tags: 2 columns Column 1: tag_reg varchar(16) Column 2: time_reg timestamp 1. Now I'm loading the Registered_tags table with a text file that has tag_reg data but need the timestamp to be put automatically when the row is added to that table.. The query is: load data infile "expected.txt" into table registered_tags lines terminated by 'rn' But all the timestamp values i get in the table are 0000-00-00 00:00:00 I've tried putting in NOW() and NULL for the field value in the text file but same thing.. 2. I need to compare the "tag_in" column in Handheld_tags table with the "tag_reg" column in Registered_tags table... - To see the common entries in these two columns.. - To see whats in tag_in column and not in tag_reg and vice versa.. How do i go about this ? Thnak you for your help..

Answer Wiki

Thanks. We'll let you know when a new response is added.

I’m not sure how well this is going to display here, but:

1: LOAD DATA INFILE ‘expected.txt’ INTO TABLE registered_tags FIELDS TERMINATED BY ‘,’ ENCLOSED BY ” LINES TERMINATED BY ‘n’ STARTING BY ”

This figures your fields are comma delimited, one record per line.

2a: SELECT * FROM Handheld_tags a,Registered_tags b WHERE a.tag_in=b.tag_reg

2b: SELECT * FROM Handheld_tags WHERE tag_in NOT IN (SELECT tag_reg FROM Registered_tags )

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following