SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Query Problem

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query Problem

    What is wrong in this code

    Code MySQL:
    $query = "SELECT ledger.bill_no,ledger.ref_no,ledger.bill_date,ledger.insurers,ledger.issuing_office,ledger.insured_name,ledger.vehicle_no,ledger.vehicle,ledger.type_of_report,sfb.insured_address,sfb.prof_fees,sfb.prof_fees_desc,sfb.photos_nos,sfb.photos,sfb.conveyance_desc,sfb.conveyance,sfb.halting_desc,sfb.halting,sfb.misc_desc,sfb.misc,sfb.total,sfb.service_tax_rate,sfb.service_tax,sfb.survey_fees,sfb.in_words,sfb.remarks FROM ledger,sfb WHERE ledger.bill_no='$bill_no' AND sfb.bill_no='$bill_no'";

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    Why? Do you get an error? A result you didn't expect?

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    what's
    wrong?
    you
    mean,
    other
    than
    the
    fact
    that
    the
    query
    is
    all
    strung
    out
    on
    a
    single
    humoungously
    long
    line
    which
    makes
    it
    almost
    impossible
    for
    a
    human
    being
    to
    read
    and
    understand?

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    what's
    wrong?
    you
    mean,
    other
    than
    the
    fact
    that
    the
    query
    is
    all
    strung
    out
    on
    a
    single
    humoungously
    long
    line
    which
    makes
    it
    almost
    impossible
    for
    a
    human
    being
    to
    read
    and
    understand?

    ohh...
    I changed the query to

    HTML Code:
    SELECT ledger.bill_no,ledger.ref_no,ledger.bill_date,ledger.insurers,ledger.issuing_office,
    	      ledger.insured_name,ledger.vehicle_no,ledger.vehicle,ledger.type_of_report,sfb.insured_address,
    		  sfb.prof_fees,sfb.prof_fees_desc,sfb.photos_nos,sfb.photos,sfb.conveyance_desc,sfb.conveyance,
    		  sfb.halting_desc,sfb.halting,sfb.misc_desc,sfb.misc,sfb.total,sfb.service_tax_rate,sfb.service_tax,
    		  sfb.survey_fees,sfb.in_words,sfb.remarks FROM ledger
    		  INNER JOIN sfb ON ledger.bill_no=sfb.bill_no WHERE ledger.bill_no='$bill_no'";
    There are 72 record are in ledger table & 2 record are in sfb table with bill_no in both tables. I am getting same insured_address & same prof_fees if I supply different bill no.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    it's gotta be a data problem, your join is fine
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks Mr r937, yeah i got the solution. I was becoz of difference between # of rows in both tables. I sorted out the problem. Now in both tables I have same number of rows 73 record in boths tables & now the query is working fyn


Bookmarks

Posting Permissions

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