Sql query -Results from 2 tables

Posted on 2011-10-14
Last Modified: 2012-08-13
I need to write a query which checks whether a string is not present in table1 ,then look for it in table2.

sql1: SQL = "SELECT FormTable FROM " & TABForms  WHERE " & ctUcase & "(FORMTABLE) LIKE " & (CalcTable.ToUpper & WildChr, ctText)
if  FormTable  does not exists in FormTable then check it in Usertable
 sql2: SQL = " SELECT table_name   FROM user_tables where    table_name  LIKE " & (CalcTable.ToUpper & WildChr, ctText)

Any help appreciated.
Question by:RIAS
    1 Comment
    LVL 69

    Accepted Solution

    can't you just UNION them?

    SQL = "SELECT FormTable FROM " & TABForms  WHERE " & ctUcase & "(FORMTABLE) LIKE " & (CalcTable.ToUpper & WildChr, ctText)
    SQL = SQL + " UNION "
    SQL = SQL + " SELECT table_name   FROM user_tables where    table_name  LIKE " & (CalcTable.ToUpper & WildChr, ctText)

    Featured Post

    PRTG Network Monitor: Intuitive Network Monitoring

    Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

    Join & Write a Comment

    If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now