Results 1 to 2 of 2

Thread: ADO controls and SQL

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Location
    N.Ireland
    Posts
    651

    Talking

    If you are setting an ADO control's recordsource in runtime, can you have multiple where conditions?

    eg.
    If a database has two tables:
    Forms (containing Title, Author, UpdateCode) and
    UpdateDetails (containing UpdateCode, Surname)

    Could you have a statement
    "Select.... WHERE Forms.UpdateCode = UpdateDetails.UpdateCode, AND (TITLE = 'Quality Form' OR Surname = 'Bloggs')"

    Is this possible and if so, what is the syntax to set the recordset??????
    Gilly

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Talking

    Hi Gilly

    Yes you can do that, but you will need a common field that is in both tables (like updatecode in your example). You then need to do a join to get the information back. use the following code to achieve this.

    SELECT ... FROM Forms as frm INNER JOIN UpdateDetails as upd on(frm.updatecode=upd.updatecode) WHERE ..

    In the select part you can select any fields from either table using their alias (frm for form and ups for update details) eg. Select frm.updatecode,upd.*.

    And in the where statement you can have frm.TITLE = 'Quality Form' OR upd.Surname = 'Bloggs'

    Hope this helps

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width