Find value in field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Friebo
    New Member
    • Mar 2008
    • 2

    Find value in field

    Hi,

    I'm having troubles with the following:

    I have 2 tables, Candidates and Attachments. In the Candidate there is a column called email1.

    In the Attachment table, there is a column called Text filled with text. Somewhere in this text there is a email address mentioned (which is email1).

    I want to find the records where candidate.email 1 is mentioned in the attachment.text column.

    I therefore tried the following query:

    Code:
    SELECT candidate_id FROM candidate, attachment WHERE email1 IN(attachment.text)
    This is returing the correct value only if there isn't any other text in the attachment.text column, which is not the fact.

    Anyone that can help me with this?
    Last edited by Friebo; Mar 17 '08, 04:20 PM. Reason: -
  • Scott Price
    Recognized Expert Top Contributor
    • Jul 2007
    • 1384

    #2
    You have your email1 and attachment.text swapped. The sql you have is looking IN email1 FOR attachment.text .

    Regards,
    Scott

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      Also, if you actually have a column/field named Text you need to change the name to something else; Text is a Reserved Word in Access, and sooner or later it'll cause you trouble.

      Welcome to TheScripts!

      Linq ;0)>

      Comment

      • Friebo
        New Member
        • Mar 2008
        • 2

        #4
        Originally posted by missinglinq
        Also, if you actually have a column/field named Text you need to change the name to something else; Text is a Reserved Word in Access, and sooner or later it'll cause you trouble.

        Welcome to TheScripts!

        Linq ;0)>
        Thank you both, I've managed to accomplish it by extracting the email addresses out of the text in excel. However, when I want to run the query
        Code:
         UPDATE attachment SET attachment.data_item_id= (SELECT Distinct candidate_id FROM candidate, attachment
        WHERE candidate.email1= attachment.email);
        I'm getting the error "Operation must use an updateable query." I don't see what I'm doing wrong here. Both the attachment.data _item_id and Candidate.candi date_id are numeric and the tables are having a Primary Key.

        Running the Select query apart from the Update query does return the expected value.
        Last edited by Friebo; Mar 19 '08, 03:00 PM. Reason: additional info

        Comment

        Working...