Results 1 to 6 of 6
  1. #1

    Default SQL Query 2 Tables


    Guys anybody has an idea or is it feasible to return this data using a particular query?


  2. #2
    bro, i'm willing to help however our firewall is blocking any attachments. is it possible to have it as plain text?

  3. #3
    Medyo pareha man ni atong usa ka post last week.

    Use joins (left outer/inner, right... etc... in mysql):

    e.g.

    SELECT T1.CSTH, T1.SEIB, T1.BUBA, T1.QTYINVCD, T2.QTYINVCD_2, T1.IPADDRESS
    FROM TABLE1 T1
    LEFT OUTER JOIN TABLE2 T2 ON T1.CSTH = T2.CSTH
    (assuming T1.CSTH = T2.CSTH foreign key)

    i'm not sure if this will return your expected output wala ko ni na-test sa ako local but sulayi lang. try experimenting with joins.

  4. #4
    Quote Originally Posted by maddox22 View Post
    Medyo pareha man ni atong usa ka post last week.

    Use joins (left outer/inner, right... etc... in mysql):

    e.g.



    (assuming T1.CSTH = T2.CSTH foreign key)

    i'm not sure if this will return your expected output wala ko ni na-test sa ako local but sulayi lang. try experimenting with joins.
    the query would return 5695 rows

  5. #5
    Quote Originally Posted by dlanyer77 View Post
    bro, i'm willing to help however our firewall is blocking any attachments. Is it possible to have it as plain text?
    table1:
    Csth seib buba qtyinvcd ipadress
    ==================================
    6845 | 76220 | t159 | 10000 | 172.29.8.28
    6845 | 76220 | t159 | 10000 | 172.29.8.28
    6845 | 76220 | t159 | 10000 | 172.29.8.28
    6845 | 76220 | t159 | 20000 | 172.29.8.28

    table2:
    Csth seib buba qtyinvcd_2 ipadress
    ==================================
    6845 | 76220 | t159 | 50000 | 172.29.8.28
    6845 | 76220 | t159 | -20000 | 172.29.8.28
    6845 | 76220 | t159 | 20000 | 172.29.8.28

    expected result:
    Csth seib buba qtyinvcd qtyinvcd_2 ipadress
    ===========================================
    6845 | 76220 | t159 | 10000 | 50000 | 172.29.8.28
    6845 | 76220 | t159 | 10000 |-20000 | 172.29.8.28
    6845 | 76220 | t159 | 10000 | 20000 | 172.29.8.28
    6845 | 76220 | t159 | 20000 | 0 | 172.29.8.28

  6. #6
    select t1.csth, t1.seib, t1.buba, t1.qtyinvcd, t2.qtyinvcd_2, t1.ipadress from table1 t1 inner join table2 t2 on t1.csth = t2.csth
    group by t1.csth


    -- use inner join and group by 'csth'

  7.    Advertisement

Similar Threads

 
  1. Replies: 12
    Last Post: 05-07-2009, 02:36 PM
  2. Need help MYSQL Query on dynamic table..
    By salbahis in forum Programming
    Replies: 6
    Last Post: 11-15-2008, 11:25 AM
  3. need help on a sql query: :)
    By silent-kill in forum Programming
    Replies: 19
    Last Post: 11-04-2008, 09:17 PM
  4. Need help regarding sql query
    By DeathFox in forum Programming
    Replies: 12
    Last Post: 07-22-2008, 06:41 PM
  5. Replies: 3
    Last Post: 06-16-2007, 12:45 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