Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1

    Default How to use select join


    guys, i need ur help how to use join in vb ...especially in query?

  2. #2
    Hi, my work is with database department

    I can help you explain basics of join. Usually we call it equi-join.
    When you join multiple tables. It could be: 1 is to 1, 1 is to many, or many is to 1.

    The standard of equi-join number of tables minus 1:
    For example if you have 6 tables, you should perform equi-join in 5 conditions. You can perform more than 5 conditions if want it to be more strict.

    Example of 3 tables, with 2 equi-join conditions.
    this EQUI-JOIN serving employee table as the center point.
    Code:
    SELECT emp.employee_id, dept.department_id , comp.company_id
    FROM 
    company as comp,
    employee as emp,
    department as dept
    WHERE comp.company_id = emp.company_id -- equi join company ID
    AND  dept.deptartment_id= emp.department_id -- equi join department ID
    Last edited by dodie; 11-26-2010 at 05:45 PM.

  3. #3
    Quote Originally Posted by skeptic_rob View Post
    guys, i need ur help how to use join in vb ...especially in query?
    bro, e specify kuno unsay imo buhaton... ang sample code ni dodie ok naman na... but it depends kung unsay program imo buhaton sa imo vb w/ respect sa query...

  4. #4
    Dim RS As New ADODB.Recordset

    RS.Open " select ID1,FIRSTNAME FROM PEOPLE c1 inner join STUDENT s2 where s2.ID1 = c1.ID", conn, adOpenDynamic, adLockOptimistic
    With RS
    RS!ID = TXTID.Text
    RS!STUDENTNAME = TXTSTUDENTNAME.Text
    'RS.Update
    End With
    In ani bro ako man g try ug test dli lagi mo work ..wla lagi changes sa database

  5. #5
    Quote Originally Posted by skeptic_rob View Post
    Dim RS As New ADODB.Recordset

    RS.Open " select ID1,FIRSTNAME FROM PEOPLE c1 inner join STUDENT s2 where s2.ID1 = c1.ID", conn, adOpenDynamic, adLockOptimistic
    With RS
    RS!ID = TXTID.Text
    RS!STUDENTNAME = TXTSTUDENTNAME.Text
    'RS.Update
    End With
    In ani bro ako man g try ug test dli lagi mo work ..wla lagi changes sa database
    isuwat daw tanan tables and mga fields sa table.

    im trying msaccess para sa mga join table.
    sayon rana sa msaccess.

  6. #6
    Quote Originally Posted by skeptic_rob View Post
    Dim RS As New ADODB.Recordset

    RS.Open " select ID1,FIRSTNAME FROM PEOPLE c1 inner join STUDENT s2 where s2.ID1 = c1.ID", conn, adOpenDynamic, adLockOptimistic
    With RS
    RS!ID = TXTID.Text
    RS!STUDENTNAME = TXTSTUDENTNAME.Text
    'RS.Update
    End With
    In ani bro ako man g try ug test dli lagi mo work ..wla lagi changes sa database

    Of course walai changes sa db, because you are executing a select query, not an update/create statement..

    JOINS are useful for creating views and executing one query involving 2 or more tables instead of multiple queries.


    About your select statement above; That only selects the columns ID1 and FirstName from table PEOPLE providing that the predicate statement in your join is true. However the data to be stored in your recordset is just a virtual table (some sort of view), the result of your query.

    Im not an expert in vb6; but maybe that didnt save because that table never really existed, its only a virtual table.

    By the way, you're using a SQL statement to retrieve data, why not use an sql statement for update? Its supposed to be that way.

    Connection.ExecuteNonQuery, sa ako ng nahinumdoman..

    skeptic_rob, you're from UC?

  7. #7
    Quote Originally Posted by skeptic_rob View Post
    Dim RS As New ADODB.Recordset

    RS.Open " select ID1,FIRSTNAME FROM PEOPLE c1 inner join STUDENT s2 where s2.ID1 = c1.ID", conn, adOpenDynamic, adLockOptimistic
    With RS
    RS!ID = TXTID.Text
    RS!STUDENTNAME = TXTSTUDENTNAME.Text
    'RS.Update
    End With
    In ani bro ako man g try ug test dli lagi mo work ..wla lagi changes sa database
    Hehehe.. murag ang imong gusto mahitabo kay either INSERT or UPDATE but sa imong query you are using SELECT mao nga dili jud na mo work..

  8. #8
    Quote Originally Posted by Cybernaut View Post
    Hehehe.. murag ang imong gusto mahitabo kay either INSERT or UPDATE but sa imong query you are using SELECT mao nga dili jud na mo work..
    bitaw noh hahahahahah
    mag istorya sa multiple tables para UPDATE kaysa SELECT.

    Food for Thought

    WARNING!!!!
    JOIN, LEFT JOIN , "traditional condition" .. performs differently. I rather suggest the traditional condition for equi-joins.

    Let's get back to basics this time... about UPDATE.
    previously I exampled this.
    Code:
    SELECT emp.employee_id, dept.department_id , comp.company_id
    FROM 
    company as comp,
    employee as emp,
    department as dept
    WHERE comp.company_id = emp.company_id -- equi join company ID
    AND  dept.deptartment_id= emp.department_id -- equi join department ID
    If we want to perform UPDATE to Multiple tables. We could do this. Re-using same table syntax, and conditions.
    Code:
    UPDATE
    company as comp,
    employee as emp,
    department as dept
    SET   employe.somethingcolumn = somthingtable.somethingcolumn
    WHERE comp.company_id = emp.company_id -- equi join company ID
    AND  dept.deptartment_id= emp.department_id -- equi join department ID
    Last edited by dodie; 12-01-2010 at 07:14 PM.

  9. #9
    programmers should always apply the most simple solutions to a problem. add lang ko.

    if you want your queries to be flexible in most db server use the basic in joining tables like join, left join, right join, union --> for merging more than one dataset into one.

    - To use sql update statement
    UPDATE table SET field1=actual value WHERE condition here



    FREE advertising: Company, Job openings & resume
    @ Cebujobline.com

  10. #10
    @Dodiebax

    bout your food for thought.


    WARNING!!!!
    JOIN, LEFT JOIN , "traditional condition" .. performs differently. I rather suggest the traditional condition for equi-joins.
    That depends on what you are trying to do, your equi-join is like an inner join statement, RIGHT and LEFT joins have their purpose also.

    There are things your equi-join can't do, so please do take off the warning. Those JOIN statements are useful..

    lol..

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. how to use a vonage broadband phone with globe dsl?
    By king_coy in forum Networking & Internet
    Replies: 6
    Last Post: 05-22-2006, 09:09 PM
  2. VIVO (video in, video out) HOW TO USE?
    By weedmeister in forum Computer Hardware
    Replies: 6
    Last Post: 05-08-2006, 08:56 AM
  3. how to use ADODC in Visual Basic
    By arbie_mon in forum Software & Games (Old)
    Replies: 0
    Last Post: 05-05-2006, 02:59 PM
  4. how to use RAID function
    By jamamp;jem in forum Computer Hardware
    Replies: 18
    Last Post: 01-05-2006, 03:52 PM
  5. i dont know how to use my video card
    By doki in forum Computer Hardware
    Replies: 3
    Last Post: 12-21-2005, 10:09 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
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top