Results 1 to 5 of 5
  1. #1
    Cojack is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    7

    Question SQL like statement?

    Hi Access users,



    Can you help me out?
    I would to connect/compare two tabels.

    Tabel 1
    Field: Groupname
    (example: ACROBAT)

    Tabel 2
    Field: Groupname
    Status: Status
    (example: X231-ACROBAT-10E8; finished)

    Query Result: (ACROBAT; finished)

    Would it be possible to connect these tabels with a "like" and wildcards statement? And give me the correct result?

    i'm not formiliar with VB in Access to hopefully it possible without it?

    the Query should be something like this??????

    SELECT Tabel1.GroupName
    FROM Tabel1
    INNER JOIN Tabel2
    ON Tabel1.GroupName like "*"&Tabel2.GroupName&"*";

  2. #2
    NoellaG's Avatar
    NoellaG is offline VIP
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Jun 2010
    Location
    Belgium
    Posts
    1,041
    Hi,

    you can't use the "like" operator in the join expression. You can though use functions in it: for instance
    [field1] = iif(instr([field2],"ACROBAT"),"ACROBAT").
    Be carefull, this slows the query down quite a bit.

    grNG

  3. #3
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Another way, you may try this:

    SELECT Tabel1.GroupName,table2.status
    FROM Tabel1,table2
    where Tabel1.GroupName like "*"&Tabel2.GroupName&"*" group by table1.groupname,table2.status

  4. #4
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    From your post it is not clear to me that you need to involve table 1, if table 2's status includes the group name.

    Based on what you posted all you really need is to make a select query of table 2 and put in your criteria with wild cards:

    (example: X231-ACROBAT-10E8; finished)

    Query Result: (ACROBAT; finished)

    critieria: like "*Acrobat*finished"

    but not sure I fully understand your goal. Hope this helps.

  5. #5
    Cojack is offline Novice
    Windows 7 Access 2007
    Join Date
    Sep 2010
    Posts
    7
    Quote Originally Posted by weekend00 View Post
    Another way, you may try this:

    SELECT Tabel1.GroupName,table2.status
    FROM Tabel1,table2
    where Tabel1.GroupName like "*"&Tabel2.GroupName&"*" group by table1.groupname,table2.status

    Thank you very much, this solved my issue

    Regards,

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with Iif statement
    By tmcrouse in forum Queries
    Replies: 2
    Last Post: 09-02-2010, 09:00 AM
  2. If Then Statement Help
    By Kapelluschsa in forum Programming
    Replies: 5
    Last Post: 08-11-2010, 09:24 AM
  3. IIf Statement...HELP!
    By bdhFS in forum Queries
    Replies: 5
    Last Post: 05-19-2010, 07:55 AM
  4. IIF statement
    By james1982 in forum Access
    Replies: 1
    Last Post: 07-20-2009, 09:38 AM
  5. how to use IF then statement
    By ronnie4 in forum Access
    Replies: 1
    Last Post: 03-17-2009, 11:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums